0

I am writing a component that has one required IP and three optional IPs. The catch is that even though the three latter IPs are optional, at least one of them is required. It looks something like this:

@inPorts.add 'search_term', new noflo.InPort datatype: 'string'
@inPorts.add 'category1', new noflo.InPort datatype: 'boolean'
@inPorts.add 'category2', new noflo.InPort datatype: 'boolean'
@inPorts.add 'category3', new noflo.InPort datatype: 'boolean'

So, basically, the component should perform a search in some (at least one!) category or combination of categories.

The problem is that the component has to wait until it has gathered data from all connected inputs, then search and send the result forward.

I have looked into the wirePattern / groupedInput helpers but I cannot figure out if this type of optional grouping is supported. Am I missing something trivial here? Is there an easier way of achieving this behaviour? I have also looked some into the required option on IPs, but haven't got it working.

Jonas.z
  • 415
  • 4
  • 18

1 Answers1

1

I recommend that you have only two inPorts; search_term and category. The category port could accept an object with up to three properties matching the category names.

@inPorts.add 'search_term', new noflo.InPort datatype: 'string'
@inPorts.add 'category', new noflo.InPort datatype: 'object'

# Example input object
{
  category1: true,
  category2: false,
  category3: true
}
Hayes
  • 848
  • 4
  • 10
  • Yes, this would solve my problem. However, I think this is typical of NoFlo. I may be trying to use it the wrong way, but I want to create high-level components that a non-programmer could use. This may be the best way, though. Thank you for your answer. – Jonas.z Jul 10 '14 at 07:52