Arquivos
NodeCopterHack/node_modules/ar-drone/journal/2012-11-08.md
T
2013-08-10 13:15:52 +01:00

1.1 KiB

control <-> navdata circular dependency

So I have a circular dependency between navdata and control:

  • control needs navdata to provide a callback to takeoff
  • navdata needs control to request more navdata as needed

The following solutions seem feasable:

a) Create circular dependency

Problems:

  • Nasty
  • Means I have to manipulate the navdata object after creating it to give it control.
  • Breaks the isolation of navdata and control

b) Move higher level control to client

Example:

client.takeoff();
client.land();

Problems:

  • Unclear what the client object should do and what the control object should do.

c) Have the control listen to all navdata events

Problems:

  • None, as long as I'm ok with emitting all navdata events

Side quest: emit 'data' events if not all navdata is included?

Problems:

  • may cause navdata events to not be emitted for an unknown amount of time

control internals

I'm wondering how to do the control internals, this may be right:

  • control.atStream.ref(); control.atStream.flush(); -> emits 'data' ControlMessage
  • control.atStream.pipe(control.udpStream);
  • udp emits what it is sending