ForceUniverse / dart-force

Dart Realtime Web Framework!
https://pub.dartlang.org/packages/force
Other
89 stars 9 forks source link

More toolable way to handle connecting? #12

Closed sethladd closed 10 years ago

sethladd commented 10 years ago

How about, instead of:

 forceClient.onConnecting.listen((e) {
      if (e.type=="connected") {
        ...
      } else if (e.type=="disconnected") {
        ...
      }
 });

The forceClient can return a Future that completes when the connection is complete. I'd like to try to avoid checking types against strings if possible. Hard to spellcheck and refactor and statically analyze.

Check the WebSocket class for some inspiration on how to deal with a connection that completes and disconnects.

jorishermans commented 10 years ago

You are right, this can be improved. I made a better implementation, I still need to test this to my examples.

jorishermans commented 10 years ago

Tested and it is working :) thanks for the feedback!

sethladd commented 10 years ago

Thanks!