Access metadata into component in noFlo

52 views Asked by At

I want to dynamically use some master data in noflo components. For example In my graph I will use same component in different ids. based on that I will also change the data. How to access the metada in graph into my component?

 "processes": {
    "Foo": { "component": "Bar", "metadata": { "display": { "x": 100, "y": 200 }, "hello": "World" } },
    "Bar": { "component": "Baz", "metadata": {} },
    "Bar2": { "component": "bar", "metadata": {} },
    "Bar3": { "component": "bar2", "metadata": {} }
  },

For example if this is a graph, how to access the metadata in my component? I'm using nodejs to build the custom components

2

There are 2 answers

1
Jon Nordby On BEST ANSWER

You cannot access the graph, or the metadata from a component. Input data must be passed in via the inports.

If the data of interest is configuration and is normally set once, you can use a non-triggering port.

0
bergie On

Node metadata is passed to components via an argument of the getComponent method.

const noflo = require('noflo');
exports.getComponent = (metadata) => {
  const c = new noflo.Component();
  console.log(metadata);
  // ...
};