Skip to content

Commit 1c72b01

Browse files
authored
Merge pull request #10 from pusher/ci-support
CI support for React Native SDK
2 parents 95d9994 + 8900749 commit 1c72b01

File tree

6 files changed

+57
-14
lines changed

6 files changed

+57
-14
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
on:
2+
pull_request:
3+
branches: [ master ]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Yarn install
12+
uses: actions/setup-node@v2
13+
with:
14+
node-version: ${{ matrix.node-version }}
15+
- run: yarn install --cwd example --frozen-lockfile
16+
- run: yarn install --frozen-lockfile
17+
- run: yarn typescript
18+
- run: yarn lint

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 1.0.0-beta1
4+
5+
* [FIXED] Fixed required dependencies on README
6+
* [ADDED] Add Lint support for Pull Requests
7+
* [CHANGED] Executed Lint on Example app
8+
39
## 0.0.1-beta1
410

511
* [ADDED] First beta release 🥳

example/src/App.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
Pusher,
1616
PusherMember,
1717
PusherChannel,
18-
PusherEvent
18+
PusherEvent,
1919
} from 'pusher-websocket-react-native';
2020

2121
export default function App() {
@@ -44,6 +44,8 @@ export default function App() {
4444
onChangeEventData((await AsyncStorage.getItem('DATA')) || '');
4545
};
4646
getFromStorage().catch((e) => log('ERROR: ' + e));
47+
48+
// eslint-disable-next-line react-hooks/exhaustive-deps
4749
}, []);
4850

4951
const connect = async () => {
@@ -80,7 +82,9 @@ export default function App() {
8082
currentState: string,
8183
previousState: string
8284
) => {
83-
log(`onConnectionStateChange. previousState=${previousState} newState=${currentState}`);
85+
log(
86+
`onConnectionStateChange. previousState=${previousState} newState=${currentState}`
87+
);
8488
};
8589

8690
const onError = (message: string, code: Number, error: any) => {
@@ -101,7 +105,11 @@ export default function App() {
101105
log(`Me: ${me}`);
102106
};
103107

104-
const onSubscriptionError = (channelName: string, message: string, e: any) => {
108+
const onSubscriptionError = (
109+
channelName: string,
110+
message: string,
111+
e: any
112+
) => {
105113
log(`onSubscriptionError: ${message}, channelName: ${channelName} e: ${e}`);
106114
};
107115

@@ -174,7 +182,7 @@ export default function App() {
174182
<Button
175183
title="Connect"
176184
onPress={connect}
177-
disabled={!Boolean(apiKey && cluster && channelName)}
185+
disabled={!(apiKey && cluster && channelName)}
178186
/>
179187
</>
180188
) : (
@@ -207,7 +215,7 @@ export default function App() {
207215
<Button
208216
title="Trigger Event"
209217
onPress={trigger}
210-
disabled={!Boolean(eventName)}
218+
disabled={!eventName}
211219
/>
212220
</>
213221
)}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pusher/pusher-websocket-react-native",
3-
"version": "0.0.1-beta1",
3+
"version": "1.0.0-beta1",
44
"description": "Pusher Channels Client for React Native",
55
"main": "lib/commonjs/index",
66
"module": "lib/module/index",

scripts/bootstrap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const options = {
1212
};
1313

1414
if (os.type() === 'Windows_NT') {
15-
options.shell = true
15+
options.shell = true;
1616
}
1717

1818
let result;

src/index.tsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export class PusherChannel {
8484
}
8585

8686
async trigger(event: PusherEvent) {
87-
if (event.channelName != this.channelName) {
87+
if (event.channelName !== this.channelName) {
8888
throw 'Event is not for this channel';
8989
}
9090
return Pusher.getInstance().trigger(event);
@@ -129,7 +129,11 @@ export class Pusher {
129129
onError?: (message: string, code: Number, e: any) => void;
130130
onEvent?: (event: PusherEvent) => void;
131131
onSubscriptionSucceeded?: (channelName: string, data: any) => void;
132-
onSubscriptionError?: (channelName: string, message: string, e: any) => void;
132+
onSubscriptionError?: (
133+
channelName: string,
134+
message: string,
135+
e: any
136+
) => void;
133137
onDecryptionFailure?: (eventName: string, reason: string) => void;
134138
onMemberAdded?: (channelName: string, member: PusherMember) => void;
135139
onMemberRemoved?: (channelName: string, member: PusherMember) => void;
@@ -161,7 +165,7 @@ export class Pusher {
161165
const userInfo = decodedData?.presence?.hash[_userId];
162166
var member = new PusherMember(_userId, userInfo);
163167
channel?.members.set(member.userId, member);
164-
if (_userId == userId) {
168+
if (_userId === userId) {
165169
channel!.me = member;
166170
}
167171
}
@@ -207,9 +211,12 @@ export class Pusher {
207211
}
208212
});
209213

210-
this.addListener('onSubscriptionError', async ({ channelName, message, type }) => {
211-
args.onSubscriptionError?.(channelName, message, type);
212-
});
214+
this.addListener(
215+
'onSubscriptionError',
216+
async ({ channelName, message, type }) => {
217+
args.onSubscriptionError?.(channelName, message, type);
218+
}
219+
);
213220

214221
return PusherWebsocketReactNative.initialize({
215222
apiKey: args.apiKey,
@@ -236,7 +243,11 @@ export class Pusher {
236243
async subscribe(args: {
237244
channelName: string;
238245
onSubscriptionSucceeded?: (data: any) => void;
239-
onSubscriptionError?: (channelName: string, message: string, e: any) => void;
246+
onSubscriptionError?: (
247+
channelName: string,
248+
message: string,
249+
e: any
250+
) => void;
240251
onMemberAdded?: (member: PusherMember) => void;
241252
onMemberRemoved?: (member: PusherMember) => void;
242253
onEvent?: (event: PusherEvent) => void;

0 commit comments

Comments
 (0)