From ed5ba541371857ff79a33689b8c6e4706ffe4374 Mon Sep 17 00:00:00 2001 From: traducer Date: Thu, 7 Jul 2016 09:46:14 +0000 Subject: [PATCH] updated readme example for subscriptions, sending data from inside a model expects exactly 3 arguments --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 836cf6b..ced5ebd 100644 --- a/README.md +++ b/README.md @@ -302,7 +302,11 @@ app.model({ namespace: 'app', subscriptions: [ (send, done) => { - setInterval(() => send('app:print', { payload: 'dog?' }), 1000) + setInterval(() => { + send('app:print', { payload: 'dog?', myOtherValue: 1000 }, (err) => { + if (err) return done(err) + }) + }, 1000) } ], effects: { @@ -399,11 +403,13 @@ arguments: - __subscriptions:__ asynchronous read-only operations that don't modify state directly. Can call `actions`. Signature of `(send, done)`. -#### send(actionName, data?) +#### send(actionName, data?[,callback]) Send a new action to the models with optional data attached. Namespaced models can be accessed by prefixing the name with the namespace separated with a `:`, e.g. `namespace:name`. +When sending data from inside a `model` it expects exactly three arguments: the name of the action you're calling, the data you want to send, and finally a callback to handle errors through the global `onError()` hook. So if you want to send two values, you'd have to either send an array or object containing them. + #### done(err?, res?) When an `effect` or `subscription` is done executing, or encounters an error, it should call the final `done(err, res)` callback. If an `effect` was called