Skip to content

Conversation

dennis-tra
Copy link
Contributor

With this snippet I ran into a race condition

  var remoteDevtools = RemoteDevToolsMiddleware('localhost:8000');

  final store = DevToolsStore<AppState>(
    appReducer,
    initialState: AppState.initialState(),
    middleware: []
      ..add( my middlewares )
      ..add(remoteDevtools),
  );
  remoteDevtools.store = store;

  await remoteDevtools.connect();

  store.dispatch(Action1());
  store.dispatch(Action2());

after the await remoteDevtools.connect(); has resolved the connection is actually not yet established but it is in the starting state. The lead to my first dispatched actions not to appear in the Remote Dev Portal. The condition for forwarding actions is this.status == RemoteDevToolsStatus.started which was not the case yet.

This pull request waits until the remote dev tools have responded with START and then resolves the connect() functions.

@dennis-tra dennis-tra force-pushed the master branch 2 times, most recently from f92c4c2 to 147d352 Compare July 9, 2019 17:50
@MichaelMarner
Copy link
Owner

LGTM. Would you be able to update the tests and make them pass? Looks like just updating the mocks to simulate receiving the START message from a server.

@coveralls
Copy link

coveralls commented Jul 11, 2019

Pull Request Test Coverage Report for Build 90

  • 8 of 9 (88.89%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.9%) to 91.667%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/src/remote_devtools_middleware.dart 8 9 88.89%
Totals Coverage Status
Change from base Build 85: 0.9%
Covered Lines: 88
Relevant Lines: 96

💛 - Coveralls

@dennis-tra
Copy link
Contributor Author

@MichaelMarner I updated the tests 👍

@MichaelMarner
Copy link
Owner

Awesome, thanks for the contribution!

@MichaelMarner MichaelMarner merged commit 41b88a4 into MichaelMarner:master Jul 11, 2019
@MichaelMarner
Copy link
Owner

This is now live in 0.0.9 on pub.dev

@dennis-tra
Copy link
Contributor Author

Perfect, thanks for merging :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants