Example boilerplate for flow components.
Hi Peter/Martin,
This is more a question rather than an issue!
Is it possible to put an example boilerplate component code for developers who want to add their own kind of components to Totaljs Flow?
Ideally, I am having trouble understanding how a component "fits together" in terms of inputs, outputs and logic performed by the component.
For instance, if I have a component that needs to take 2 numbers and add them together and send that to an output... How would one construct a simple component that achieves such a feature in terms of Inputs / Logic / Output?
Fantastic Library! Loving the flow components you have built so far! Looking to build a few of my own.
Hi @inventclem, yes, I want to prepare a Wiki for it https://wiki.totaljs.com/flow/05-creating-components/ but it's uncompleted yet.
in terms of inputs, outputs and logic performed by the component: it's very easy to understand. Imagine some component:
// INPUTS (receiving data):
instance.on('data', function(response) {
// the component received data to some input
});
instance.on('0', function(response) {
// the component received data to the INPUT 0
});
instance.on('1', function(response) {
// the component received data to the INPUT 1
});
instance.on('2', function(response) {
// the component received data to the INPUT 2
});
// OUTPUTS (send data next)
// Sending data to all outputs
instance.send({ your: 'data' });
instance.send('Peter');
// Sending data to output 0
instance.send(0, { your: 'data' });
// Sending data to output 1
instance.send(1, 'Peter');
// Sending data to output 2
instance.send(2, <buffer ...>);
Together:
instance.on('data', function(response) {
// We expect number to input
// Docs: https://github.com/totaljs/flow#message
// response.data contains the raw VALUE
// We increase this number
response.data += 10;
// Send data next
// So the next component receives updated number
instance.send(response);
});
Write me on Total.js messenger for more info. Thank you!
Hello, I am creating my own component on Dashboard and then send the data to a flow component. Can I use the same guideline https://wiki.totaljs.com/flow/05-creating-components/ for creating Dashboard components? If I have multiple data, how do I select which one to be sent/received? Thank you.
Hi @ductran54, some features are same... try it. Our plan is to upgrade Dashboard package and improve functionality.
Hi Peter, I am wondering if there is a way to hide ... in Dashboard in release.js (basically preventing users from editing dashboard), but keep it for editing when running debug.js mode. Thank you!
~Now~ No, but you can modify a bit dashboard or we can modify it within Total.js Support (it's a work for max. 2 hours)