Access metadata into component in noFlo

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

Upvotes: 0

Views: 49

Answers (2)

bergie
bergie

Reputation: 930

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);
  // ...
};

Upvotes: 0

Jon Nordby
Jon Nordby

Reputation: 6259

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.

Upvotes: 0

Related Questions