New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-meteor

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-meteor - npm Package Compare versions

Comparing version 1.0.0-beta3 to 1.0.0-beta5

lib/ddp.js

6

package.json
{
"name": "react-native-meteor",
"version": "1.0.0-beta3",
"version": "1.0.0-beta5",
"description": "DDP React-native Client",

@@ -29,8 +29,8 @@ "main": "src/Meteor.js",

"dependencies": {
"ddp.js": "1.1.0",
"ejson": "^2.1.2",
"minimongo-cache": "0.0.48",
"react-mixin": "^3.0.3",
"trackr": "^2.0.2"
"trackr": "^2.0.2",
"wolfy87-eventemitter": "^4.3.0"
}
}

@@ -15,3 +15,3 @@ [![GitHub version](https://badge.fury.io/gh/inProgress-team%2Freact-native-meteor.svg)](https://badge.fury.io/gh/inProgress-team%2Freact-native-meteor)

Meteor-like methods for React Native. **Currently in v1.0.0-beta3** ! For old docs, see [v0.6.2 documentation](https://github.com/inProgress-team/react-native-meteor/tree/0.6.2) (classic ddp interface).
Meteor-like methods for React Native. **Currently in v1.0.0-beta5** ! For old docs, see [v0.6.2 documentation](https://github.com/inProgress-team/react-native-meteor/tree/0.6.2) (classic ddp interface).

@@ -90,6 +90,4 @@ ## What is it for ?

```javascript
Meteor.publish('todos', function(selector, options){
var selector = selector || {};
var options = options || {};
return Todos.find(selector, options);
Meteor.publish('todos', function(done, options){
return Todos.find({ done: done }, options);
});

@@ -101,10 +99,6 @@ ```

//Meteor subscribe can be used like on meteor official site
Meteor.subscribe('todos', {status: 'done'}, {limit: 10, sort: {createdAt: -1}});
Meteor.subscribe('todos', true, {limit: 10, sort: {createdAt: -1}});
```
##### NOTE
- Meteor subscribe parameter still not supporting EJSON, so you can't pass param value like date, boolean etc. For now it's only support object of string (JSON)
- Meteor subscribe parameter already support Publish Composite. If you are using this package, related published collections will be available too in subscriptions.
## getMeteorData

@@ -125,3 +119,3 @@

## Meteor.connect(endpoint)
## Meteor.connect(endpoint, options)

@@ -133,3 +127,11 @@ Connect to a DDP server. You only have to do this once in your app.

- `url` **string** *required*
- `options` **object** Available options are :
- autoConnect **boolean** [true] whether to establish the connection to the server upon instantiation. When false, one can manually establish the connection with the Meteor.ddp.connect method.
- 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.
## Meteor.disconnect()
Disconnect from the DDP server.
## Meteor methods

@@ -141,4 +143,2 @@

##### NOTE
Meteor call parameter still not supporting EJSON, so you can't pass param value like date, boolean etc. For now it's only support object of string (JSON)

@@ -148,4 +148,11 @@ ## Meteor.ddp

Once connected to the ddp server, you can access every method available in [ddp.js](https://github.com/mondora/ddp.js/).
* Meteor.ddp.on('connected')
* Meteor.ddp.on('added')
* Meteor.ddp.on('changed')
* ...
# TODO
- [ ] [EJSON parameters support in subscribe and call](https://github.com/inProgress-team/react-native-meteor/issues/7)
Pull Requests are welcome ! :)

@@ -20,14 +20,19 @@ import minimongo from 'minimongo-cache';

_cbsLoggingIn: [],
_subscribeLoggingIn(cb) {
this._cbsLoggingIn.push(cb);
_cbs: [],
on(eventName, cb) {
this._cbs.push({
eventName: eventName,
callback: cb
});
},
_unsubscribeLoggingIn(cb) {
this._cbsLoggingIn.splice(this._cbsLoggingIn.indexOf(cb));
off(eventName, cb) {
this._cbs.splice(this._cbs.findIndex(_cb=>_cb.callback == cb && _cb.eventName == eventName));
},
_notifyLoggingIn() {
for(var i in this._cbsLoggingIn) {
this._cbsLoggingIn[i]();
}
this._cbs.map(cb=>{
if(cb.eventName=='loggingIn' && typeof cb.callback=='function') {
cb.callback();
}
});
}
}
import reactMixin from 'react-mixin';
import Trackr from 'trackr';
import DDP from 'ddp.js';
import DDP from '../lib/ddp.js';

@@ -52,13 +52,23 @@ import Data from './Data';

},
connect(endpoint) {
disconnect() {
if(Data.ddp) {
Data.ddp.disconnect();
}
},
connect(endpoint, options) {
this.ddp = Data.ddp = new DDP({
endpoint: endpoint,
SocketConstructor: WebSocket
SocketConstructor: WebSocket,
...options
});
Data.ddp.on("connected", ()=>{
console.info("connected");
console.info("Connected to DDP server.");
this._loadInitialUser();
});
Data.ddp.on("disconnected", ()=>{
console.info("Disconnected from DDP server.");
});
Data.ddp.on("added", message => {

@@ -65,0 +75,0 @@ if(!Data.db[message.collection]) {

@@ -46,4 +46,7 @@ import Trackr from 'trackr';

}
if(this._loggingInCallback) {
Data._unsubscribeLoggingIn(this._loggingInCallback);
if(this._meteorChangeCallback) {
Data.db.off('change', this._meteorChangeCallback);
Data.ddp.off('connected', this._meteorChangeCallback);
Data.ddp.off('disconnected', this._meteorChangeCallback);
Data.off('loggingIn', this._meteorChangeCallback);
}

@@ -80,35 +83,13 @@

component._meteorFirstRun = false;
component._meteorChangeCallback = () => { updateData(component); };
updateData(component);
Data.db.on('change', (records)=>{
updateData(component);
});
Data.ddp.on('connected', ()=> {
updateData(component);
});
Data.ddp.on('disconnected', ()=> {
updateData(component);
});
Data.db.on('change', component._meteorChangeCallback);
Data.ddp.on('connected', component._meteorChangeCallback);
Data.ddp.on('disconnected', component._meteorChangeCallback);
Data.on('loggingIn', component._meteorChangeCallback);
component._loggingInCallback = ()=> {
updateData(component);
};
Data._subscribeLoggingIn(component._loggingInCallback);
}
//console.log('WATCH');
/*
Trackr.autorun(() => {
console.log('AUTORUN');
});
Trackr.afterFlush(() => {
console.log('AFTER FLUSH');
console.log(component.getMeteorData().todos.length);
component._meteorCalledSetState = true;
component.setState(partialData);
});
*/
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc