![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
A javascript isomorphic/universal ddp client.
Warning
ddp.js@^2.0.0
is only distributed as annpm
module instead of an UMD bundle. Also,bower
has been removed as a method of distribution. If you need an UMD bundle orbower
support, I'm open for suggestions to add back those methods of distribution without polluting this repo.
The purpose of this library is:
npm install ddp.js
const DDP = require("ddp.js");
const options = {
endpoint: "ws://localhost:3000/websocket",
SocketConstructor: WebSocket
};
const ddp = new DDP(options);
ddp.on("connected", () => {
console.log("Connected");
});
const subId = ddp.sub("mySubscription");
ddp.on("ready", message => {
if (message.subs.includes(subId)) {
console.log("mySubscription ready");
}
});
ddp.on("added", message => {
console.log(message.collection);
});
const myLoginParams = {
user: {
email: "user@example.com"
},
password: "hunter2"
};
const methodId = ddp.method("login", [myLoginParams]);
ddp.on("result", message => {
if (message.id === methodId && !message.error) {
console.log("Logged in!");
}
});
After cloning the repository, install npm
dependencies with npm install
.
Run npm test
to run unit tests, or npm run dev
to have mocha
re-run your
tests when source or test files change.
To run e2e tests, first install meteor. Then,
start the meteor server with npm run start-meteor
. Finally, run
npm run e2e-test
to run the e2e test suite, or npm run e2e-dev
to have
mocha
re-run the suite when source or test files change.
Creates a new DDP instance. After being constructed, the instance will establish a connection with the DDP server and will try to maintain it open.
options
object requiredAvailable options are:
endpoint
string required: the location of the websocket server. Its
format depends on the type of socket you are using.
SocketConstructor
function required: the constructor function that
will be used to construct the socket. Meteor (currently the only DDP server
available) supports websockets and SockJS sockets. So, practically speaking,
this means that on the browser you can use either the browser's native
WebSocket constructor or the SockJS constructor provided by the SockJS
library. On the server you can use whichever library implements the
websocket protocol (e.g. faye-websocket).
autoConnect
boolean optional [default: true
]: whether to establish
the connection to the server upon instantiation. When false
, one can
manually establish the connection with the connect
method.
autoReconnect
boolean optional [default: 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 optional [default: 10000]: the interval in ms
between reconnection attempts.
A new DDP instance, which is also an EventEmitter
instance.
Calls a remote method.
name
string required: name of the method to call.
params
array required: array of parameters to pass to the remote
method. Pass an empty array if you do not wish to pass any parameters.
The unique id
(string) corresponding to the method call.
Server code:
Meteor.methods({
myMethod (param_0, param_1, param_2) {
/* ... */
}
});
Client code:
const methodCallId = ddp.method("myMethod", [param_0, param_1, param_2]);
Subscribes to a server publication.
name
string required: name of the server publication.
params
array required: array of parameters to pass to the server
publish function. Pass an empty array if you do not wish to pass any
parameters.
The unique id
(string) corresponding to the subscription call.
Server code:
Meteor.publish("myPublication", (param_0, param_1, param_2) {
/* ... */
});
Client code:
const subscriptionId = ddp.sub("myPublication", [param_0, param_1, param_2]);
Unsubscribes to a previously-subscribed server publication.
id
string required: id of the subscription.The id
corresponding to the subscription call (not of much use, but I return
it for consistency).
Connects to the ddp server. The method is called automatically by the class
constructor if the autoConnect
option is set to true
(default behaviour).
So there generally should be no need for the developer to call the method
themselves.
None
None
Disconnects from the ddp server by closing the WebSocket
connection. You can
listen on the disconnected
event to be notified of the disconnection.
None
None
connected
: emitted with no arguments when the DDP connection is
established.
disconnected
: emitted with no arguments when the DDP connection drops.
All the following events are emitted with one argument, the parsed DDP message. Further details can be found on the DDP spec page.
ready
nosub
added
changed
removed
All the following events are emitted with one argument, the parsed DDP message. Further details can be found on the DDP spec page.
result
updated
FAQs
ddp javascript client
We found that mic-ddp demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.