0

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

Jaydeep
  • 1,686
  • 1
  • 16
  • 29

2 Answers2

0

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.

Jon Nordby
  • 5,494
  • 1
  • 21
  • 50
  • While the sentiment is correct that generally data used in a graph should be handled via IPs, it is actually possible to access the node metadata inside a component. – bergie Dec 29 '20 at 10:00
0

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);
  // ...
};
bergie
  • 930
  • 7
  • 8