forio Toggle navigation

Operations Channel

Channels are ways for Flow.js to talk to external APIs -- primarily the underlying Epicenter APIs.

The primary use cases for the Operations Channel are:

  • publish: Call an operation.
  • subscribe: Receive notifications when an operation is called.

For example, use publish() to call an operation (method) from your model:'myMethod', myMethodParam);

For reference, an equivalent call using Flow.js custom HTML attributes is:

 <button data-f-on-click="myMethod(myMethodParam)">Click me</button>

You can also use subscribe() and a callback function to listen and react when the operation has been called:'myMethod',
     function() { console.log('called!'); } );

Use subscribe(*) to listen for notifications on all operations.

To use the Operations Channel, simply initialize Flow.js in your project.

Configuration Options


  • String

Determine when to update state. Defaults to false: always trigger updates.

Possible options are:

  • true: Never trigger any updates. Use this if you know your model state won't change based on operations.
  • false: Always trigger updates.
  • [array of operation names]: Operations in this array will not trigger updates; everything else will.
  • { except: [array of operation names] }: Operations in this array will trigger updates; nothing else will.

To set, pass this into the Flow.initialize() call in the field:

     channel: {
         run: {
             model: '',
             account: 'acme-simulations',
             project: 'supply-chain-game',
             operations: { silent: true }

To override for a specific call to the Operations Channel, pass this as the final options parameter:'myMethod', myMethodParam, { silent: true });


  • Boolean

Allow using the channel for reading data (subscribing), but disallow calls to publish. Defaults to false: allow both subscribing and publishing. If a function is provided, the function should return a Boolean value to override.



Force a check for updates on the channel, and notify all listeners.


  • executedOpns: String|Array Operations which just happened.

  • response: Any Response from the operation.

  • force: Boolean Ignore all silent options and force refresh.

  • options: Object (Optional) Overrides for the default channel options.

Return Value

  • **


Alert each subscriber about the operation and its parameters. This can be used to provide an update without a round trip to the server. However, it is rarely used: you almost always want to subscribe() instead so that the operation is actually called in the model.

Example'myMethod', myMethodResponse);


  • operation: String Name of operation.

  • value: String|Number|Array|Object Parameter values for the callback function.

Return Value

  • **


Call the operation with parameters, and alert subscribers.

Example'myMethod', myMethodParam);{
     operations: [{ name: 'myMethod', params: [myMethodParam] }]


  • operation: String|Object For one operation, pass the name of operation (string). For multiple operations, pass an object with field operations and value array of objects, each with name and params: {operations: [{ name: opn, params:[] }] }.

  • params: String|Number|Array|Object (Optional) Parameters to send to operation. Use for one operation; for multiple operations, parameters are already included in the object format.

  • options: Object (Optional) Overrides for the default channel options.

  • options.silent: Boolean Determine when to update state.

Return Value

  • $promise: Promise to complete the call.


Subscribe to changes on a channel: Ask for notification when operations are called.

     function() { console.log('called!'); });


  • operations: String|Array The names of the operations. Use * to listen for notifications on all operations.

  • subscriber: Object|Function The object or function being notified. Often this is a callback function.

Return Value

  • String: An identifying token for this subscription. Required as a parameter when unsubscribing.


Stop receiving notification when an operation is called.


  • operation: String|Array The names of the operations.

  • token: String The identifying token for this subscription. (Created and returned by the subscribe() call.)

Return Value

  • **


Stop receiving notifications for all operations. No parameters.

Return Value

  • **