Search code examples
javascriptangularflux

Are all Flux for Angular Libraries Experimental?


Facebook React can use a unidirectional data flow pattern called Flux to give structure to applications by using Views, Actions, Stores and a Dispatcher.

I have found the following Flux libraries for Angular:

  1. ng-flux: https://github.com/JustinWinthers/ng-flux
  2. angular-flux: https://github.com/brentvatne/angular-flux
  3. song-flux: https://github.com/gah-boh/song-flux
  4. And this sample: http://victorsavkin.com/post/99998937651/building-angular-apps-using-flux-architecture

Are any of these production ready?

Which ones have plans to migrate to Angular2 and integrate with the Component Router?

I can't seem to find any large application samples using any of these libraries. Additional links would be useful.


Solution

  • I authored ng-flux and I wouldn't say it's production ready since I haven't had the time to test it in a variety of projects. However I am using it in a fairly large enterprise class application currently. I agree that flux-angular has a good team around it and I'd recommend their library. Regardless, flux is simply a pattern that you can incorporate on your own. The issue with any Angular 1.x based approach is always the way Angular manages digest cycles and you have to sometimes jump through hoops for views to update in the background if you process data outside of the Angular namespace. In ng-flux I force a digest cycle if one hasn't occurred.

    Flux as a pattern works well to me because it makes debugging and code separation much easier on larger projects, so my goal was to use this pattern on a project that already had substantial legacy Angular code and decrease the time it was taking to triage errors. It's an actuarial application with lots of calculations, so finding small data discrepancies fast was necessary. Writing ng-flux achieved this for me.

    Regarding Angular 2, I think it will be easy enough to incorporate Facebook's dispatcher in your project and allow it to manage data flow. I think once Angular 2 is ready, based on what I've read so far it should be easier to use third party JS libraries - especially since Angular 2 will follow more of a web component based architecture somewhat similar to React. I've even seen promises that it will be easier (or more organic) to use third party routers, etc.... If this holds true, I doubt you'll actually need a library to manage a flux based data architecture in your Angular 2 apps. It should be fairly seamless to simply use something like the Facebook Dispatcher as a singleton (properly namespaced) object in your app that you can reference in your Angular components. I think most of the library authors out there realize this - it's more a problem for Angular 1.x apps to use this pattern than it will/should be for Angular 2 apps.

    https://github.com/facebook/flux/blob/master/src/Dispatcher.js