0.2.5 • Published 5 years ago

flow-if-else-component v0.2.5

Weekly downloads
4
License
Apache-2.0
Repository
github
Last release
5 years ago

Flow if-else component

The component evaluates an expression to true or false.

To use the component, in your NodeJS project, get it from npm registry

npm i flow-if-else-component --save

Use the component as below

// require the component
const Component = require('flow-if-else-component');

// create instance of the component
const component = new Component();

Provide the expression

// this can be any javascript expression, '[].length', 'a==1', ' ' and more
component.getProperty('Expression').data = 'q=1'; 

That's all, now listen in for port emit events

component.getPort('True').onEmit(function() {
  // the expression evaluated to true
});

component.getPort('False').onEmit(function() {
  // the expression evaluated to false
});

Execute the component

// add the component to a graph before executing it
const Graph = require('flow-platform-sdk').Graph;
new Graph("graph-1").addComponent(component);

component.execute();

Conclusion

That's all required to use Flow's If-else component.