Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2.6.0 #131

Merged
merged 27 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ab5a9a8
reachability options
bratelefant Jul 2, 2023
30eb39f
update docs
bratelefant Jul 2, 2023
e341348
typo
bratelefant Jul 2, 2023
65f622e
added brackets
bratelefant Jul 3, 2023
0eecae0
lint fix
bratelefant Jul 3, 2023
ab7da08
feature: define custom reachabilityUrl in Meteor.connect #120
jankapunkt Jul 4, 2023
abd9885
fixed missing reactivity of local collection in useTracker
bratelefant Jul 4, 2023
b4c0f50
removed unneccessary import
bratelefant Jul 4, 2023
d4b9113
Merge branch 'meteorrn:master' into local-collection-reactivity
bratelefant Jul 4, 2023
43aad0e
fix: local collection reactivity
jankapunkt Aug 1, 2023
5b1ea96
Fix loginWithToken when token is invalid
vforvasile Aug 10, 2023
5a7e1a3
set subs to not ready on disconnect
bratelefant Aug 19, 2023
7999b8b
also mark as unready on server disconnects
bratelefant Aug 19, 2023
6af305f
fix: attempt to use NativeEventEmitter
jankapunkt Sep 4, 2023
8dfe9cb
dev: debug NatieveEventEmitter resolve
jankapunkt Sep 5, 2023
a966361
dev: use prototype on EventEmitter to connect on/off fns
jankapunkt Sep 5, 2023
485cf38
fix: use wrapper class to provide consistent EventEmitter API
jankapunkt Sep 5, 2023
96b7e44
use EventEmitter proto from NativeEventEmitter
jankapunkt Sep 6, 2023
6fd0e17
Add _lastSessionId to ddp
bratelefant Sep 6, 2023
1b088d3
fix: use eventemitter3
jankapunkt Sep 7, 2023
623295c
Merge pull request #129 from meteorrn/fix-events
jankapunkt Sep 11, 2023
6d3a3e9
Merge pull request #128 from bratelefant/pr-set-subs-unready-on-disc
jankapunkt Sep 11, 2023
ca3206d
Fix linting
vforvasile Sep 11, 2023
ce3ce68
Merge pull request #130 from meteorrn/master
jankapunkt Sep 11, 2023
f887973
Merge pull request #126 from vforvasile/fix/token-login
jankapunkt Sep 11, 2023
c3251e0
publish 1.0.3
jankapunkt Sep 11, 2023
067c3f9
publish 2.6.0
jankapunkt Sep 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,3 @@ node_modules
.vscode
.idea
.DS_Store

7 changes: 4 additions & 3 deletions companion-packages/meteorrn-local/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,12 @@ const Local = {

LiveCol.find({}).observe({
added: async (doc) => {
LocalCol._collection.upsert(doc);
LocalCol.insert(doc);
storeLocalCol();
},
changed: async (doc) => {
LocalCol._collection.upsert(doc);
changed: async (changes, oldDoc) => {
delete changes._id;
LocalCol.update(oldDoc._id, { $set: changes });
storeLocalCol();
},
});
Expand Down
2 changes: 1 addition & 1 deletion companion-packages/meteorrn-local/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meteorrn/local",
"version": "1.0.2",
"version": "1.0.3",
"description": "Store data locally",
"main": "index.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Connect to the Meteor Server
- autoReconnect **boolean** [true] whether to try to reconnect to the server when the socket connection closes, unless the closing was initiated by a call to the disconnect method.
- reconnectInterval **number** [10000] the interval in ms between reconnection attempts.
- AsyncStorage **object** your preferred AsyncStorage. Defaults to `'@react-native-async-storage/async-storage'` as a peer dependency.
- reachabilityUrl **string** ["https://clients3.google.com/generate_204"] server to check internet reachability, used by NetInfo. If not provided, NetInfos default url will be used, which currently is `'https://clients3.google.com/generate_204'`

### `Meteor.disconnect()`

Expand Down
3 changes: 2 additions & 1 deletion lib/ddp.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EventEmitter } from 'events';
import EventEmitter from 'eventemitter3';
import Queue from './queue';
import Socket from './socket';
import { uniqueId } from './utils';
Expand Down Expand Up @@ -115,6 +115,7 @@ export default class DDP extends EventEmitter {
this.socket.on('message:in', (message) => {
if (message.msg === 'connected') {
this.status = 'connected';
this._lastSessionId = message.session;
this.messageQueue.process();
this.emit('connected');
} else if (message.msg === 'ping') {
Expand Down
2 changes: 1 addition & 1 deletion lib/socket.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EventEmitter } from 'events';
import EventEmitter from 'eventemitter3';
import EJSON from 'ejson';
import './mongo-id'; // Register mongo object ids */

Expand Down
15 changes: 11 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meteorrn/core",
"version": "2.5.1",
"version": "2.6.0",
"description": "Full Meteor Client for React Native",
"main": "src/index.js",
"repository": {
Expand Down Expand Up @@ -28,7 +28,8 @@
"homepage": "https://github.com/TheRealNate/meteor-react-native#readme",
"dependencies": {
"@meteorrn/minimongo": "1.0.1",
"ejson": "2.2.3"
"ejson": "2.2.3",
"eventemitter3": "^5.0.1"
},
"devDependencies": {
"@babel/core": "7.19.6",
Expand Down
16 changes: 16 additions & 0 deletions src/Meteor.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,16 @@ const Meteor = {

try {
const NetInfo = require('@react-native-community/netinfo').default;

if (options.reachabilityUrl) {
NetInfo.configure({
reachabilityUrl: options.reachabilityUrl,
useNativeReachability: true,
});
}

// Reconnect if we lose internet

NetInfo.addEventListener(
({ type, isConnected, isInternetReachable, isWifiEnabled }) => {
if (isConnected && Data.ddp.autoReconnect) {
Expand Down Expand Up @@ -160,6 +169,13 @@ const Meteor = {
console.info('Disconnected from DDP server.');
}

// Mark subscriptions as ready=false
for (var i in Data.subscriptions) {
const sub = Data.subscriptions[i];
sub.ready = false;
sub.readyDeps.changed();
}

if (!Data.ddp.autoReconnect) return;

if (!lastDisconnect || new Date() - lastDisconnect > 3000) {
Expand Down
2 changes: 2 additions & 0 deletions src/user/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ const User = {
}
this._loadInitialUser();
}, time + 100);
} else if (err?.error === 403) {
User.logout();
} else {
User._handleLoginCallback(err, result);
}
Expand Down