Skip to content
This repository has been archived by the owner on Nov 23, 2017. It is now read-only.
/ flux Public archive

Facebook flux inspired architecture Android sample app

Notifications You must be signed in to change notification settings

lucas34/flux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flux

Simple implementation of a counter, highly inspired by the Facebook Flux architecture.

Explanation

Facebook flux

In this case

  • Store : Contains the counter state (value)
  • Action : Possible actions such as "increment() and decrement()

The application displays two fragments side by side, the first will trigger actions base on user events and the second fragment will react. The counter on the right fragment is directly inside the fragment and the one on the right comes from the store. As you can see, they are keep showing the same number.

Implementation

Basically, the view will trigger an invoke the increment() function from action module, the latter will send the event to the store via the dispatcher, the store will update his variables and send a notification to the UI that something as change.

My implementation is based on RxJava

Plugins and side effects

According to the schema, the view should only react to the events emitted by the store. In this case the view can even react to anything. But It makes you the possibility to create plugin. I have a Logger plugin that will print on the console all the event that are triggered.

Missing features

In the facebook's implementation, they disallow Eventception

Flux allows you to have dependencies between store and wait for so actions to be executed first. So far, I haven't try to implement this such thing

Conclusion

The concept is interesting. It may be a strong solution to do reactive programmation on a large scale. My concern is only if you trigger an action in a reaction to an event. You may be in a case of an infinity event loop, debugging with this kind of architecture could be a bit tricky.

Contributors

License

Licensed under the Apache License, Version 2.0

About

Facebook flux inspired architecture Android sample app

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages