Skip to content

Instantly share code, notes, and snippets.

@Struchu
Last active June 6, 2019 18:40
Show Gist options
  • Save Struchu/460317885848194760650ba928996ea7 to your computer and use it in GitHub Desktop.
Save Struchu/460317885848194760650ba928996ea7 to your computer and use it in GitHub Desktop.
Reactive Coordinators proof of concept
import { fromEventPattern } from 'rxjs';
import authCoordinator from './authCoordinator';
export default function (screen, connector) {
// The 'q' key will quit the application no matter where the user is.
const dispose = fromEventPattern(
h => { screen.key('q', h); },
h => { screen.unkey('q', h); },
);
// The 'screen' and 'connector' are also injected in the child coordinator.
authCoordinator(screen, connector).subscribe(
token => {
/*
Do something with a token, ie.
pass control to the dashboard coordinator.
*/
},
);
return dispose;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment