6

As far as I can tell there are 7 events dispatched by a NoFlo port:

attach, connect, begingroup, data, endgroup, disconnect, detach

To me some of these events sound very similar such as attach + connect, and disconnect + detach. What is the difference?

What does begingroup and endgroup mean?

When do these events get emitted and when are they generally used?

I've seen the documentation at: http://noflojs.org/documentation/components/#portevents

Would my assumption be correct to assume that attach and detach are for handling NoFlo UI cases eg changing the state of the components look?

Another assumption would be that connect gets fired every time before data is sent? Then data gets fired. Then disconnect? Seems a bit odd to me...

I'm completely in the dark when it comes to groups.

MikkoH
  • 105
  • 3

1 Answers1

4

attach and detach happen when the NoFlo Network attaches (or removes) a socket to the port. So usually they happen at network start-up time, before IIPs get sent.

The exception to this is when you're live-editing the graph with a tool like Flowhub. In that situation attach/detach can happen whenever you connect or remove wires.

Most components don't need to care about the attachment events.

connect happens before the upstream connection sends data, and disconnect when the upstream connection says that it has sent everything it is intending to send. So in effect they're beginning of transmission and end of transmission events. An upstream component may choose to connect again after a disconnect if it has a new batch of data to send.

data is the event for actual payload-containing packets.

begingroup and endgroup are the "bracket IPs" containing metadata about the data being sent. They can be used for creating tree structures with packet data.

For example, filesystem/ReadFile will send the file contents as a data packet, but the filename is sent via a bracket IP using a begingroup/endgroup packets around the actual file contents.

The noflo-groups library provides lots of components for utilizing group information for synchronization, routing, etc.

bergie
  • 930
  • 7
  • 8
  • `detach` events can be used for shutting down or finishing things like listeners or timed events. `attach` events can be used to initialize counters, send initial values to components that need them or start long listeners and timed events. – AlfredoVR Mar 07 '14 at 23:12
  • Does ReadFile just have one connect at the beginning and a disconnect at the end, or does it have a connect/disconnect around every data? Classical FBP doesn't have that concept, so I have no idea what to expect. @bergie, you say, "...when the upstream connection says that it has sent everything it is intending to send." The only things like that in classical FBP would be the bracket IPs, which you are already handling by means of begingroup and endgroup... Also, how does the receiving process respond to a disconnect signal? – Paul Morrison Mar 08 '14 at 20:48
  • Groups are also useful for asynchronous components. "The outputs are sent in the order that they are processed, which might be a different than the order received. To keep track of the in/out data correspondence, outputs are sent with a group marked with the input data." See http://noflojs.org/documentation/async-components/ – forresto Mar 10 '14 at 17:23