DailyJS

ngPromiseStatus, fsm-event

Alex R. Young

Subscribe

@dailyjs

Facebook

Google+

libraries modules npm angularjs state-machine

ngPromiseStatus, fsm-event

Posted by Alex R. Young on .
Featured

libraries modules npm angularjs state-machine

ngPromiseStatus, fsm-event

Posted by Alex R. Young on .

ngPromiseStatus

ngPromiseStatus (GitHub: BarakChamo/ng-promise-status, License: MIT, npm: ng-promise-status) by Barak Chamo is a collection of promise-aware Angular directives that make it easy to bind UI elements to the outcome of promises. This could be a button that takes an unspecified amount of time to run, that will eventually display success or failure.

You can also bind the promise values to alerts, and the author has provided Bootstrap samples that use Bootstrap's ubiquitous .alert message boxes.

fsm-event

fsm by Dominic Tarr is a very useful module for making finite state machines. I've used it with some success on a few Node projects. However, when I'm writing Node I prefer to deal with streams and events, rather than the methods in fsm's API. Yoshua Wuyts sent in fsm-event (GitHub: hyoshuawuyts/fsm-event, License: MIT, npm: fsm-event), a wrapper that uses EventEmitter.

To use it, create a new instance of fsm with the states you need, and then call m(state) to enter a given state. The corresponding listener will fire.

Why? Most state machines have overly complicated interfaces for managing state. The fsm state machine is simple but doesn't manage state for you, so I wrote a wrapper around it that manages state in an event-driven way. The initial use case was to manage complex, stateful UI elements but it can be used anywhere.

This would have actually helped with my specific use of fsm, where I ended up using it heavily alongside EventEmitter objects.