Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Update README.md #1

wants to merge 1 commit into from

Conversation

jimbeveridge
Copy link
Owner

No description provided.

@@ -1,155 +1,236 @@
# flutter_flux

> A Dart app architecture library with uni-directional data flow inspired by [RefluxJS](https://github.com/reflux/refluxjs) and Facebook's [Flux](https://facebook.github.io/flux/).
A Dart/[Flutter](https://flutter.io) app architecture library with uni-directional data flow inspired by [RefluxJS](https://github.com/reflux/refluxjs) and Facebook's [Flux](https://facebook.github.io/flux/). [Flux](https://facebook.github.io/flux/) is the complementary “model” framework also designed by Facebook. Flutter_flux is a reimplementation of Flux that uses idiomatic Dart and integrates cleanly with Flutter.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you break the lines, it makes review much easier.

@@ -1,155 +1,236 @@
# flutter_flux

> A Dart app architecture library with uni-directional data flow inspired by [RefluxJS](https://github.com/reflux/refluxjs) and Facebook's [Flux](https://facebook.github.io/flux/).
A Dart/[Flutter](https://flutter.io) app architecture library with uni-directional data flow inspired by [RefluxJS](https://github.com/reflux/refluxjs) and Facebook's [Flux](https://facebook.github.io/flux/). [Flux](https://facebook.github.io/flux/) is the complementary “model” framework also designed by Facebook. Flutter_flux is a reimplementation of Flux that uses idiomatic Dart and integrates cleanly with Flutter.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say "A library for Flutter that implements the Flux app architecture pattern, and helps enable a uni-directional data flow...."

Drop the "Dart" part.


![flux-diagram](https://github.com/Workiva/w_flux/blob/images/images/flux_diagram.png)
The easiest ways to model state in Flutter are StatefulWidgets and global variables. StatefulWidgets are problematic because the data is destroyed whenever the widget hierarchy is destroyed. Therefore, state is lost when the route changes, and stateful widgets cannot be used for multiple views onto the same data.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found it odd that you didn't mention State here.


`flutter_flux` implements a uni-directional data flow pattern comprised of `Actions`, `Stores`, and `StoreWatchers`.
It is based on [w_flux](https://github.com/Workiva/w_flux), but modified to use Flutter instead of React.
Global variables also have issues:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They also make testing really difficult. (hard to dependency inject)


---
The Flux framework is designed to solve the problems above. The dataflow in flutter_flux looks like this.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't Flux an architectural pattern? Would it be accurate to say "Flux framework" here?

I might also use "flutter_flux library" (instead of framework)

```dart
// verbose syntax
actions.incrementCounter.listen(_handleAction);
After the `Store` updates, the view (widgets) need to update to match the new model. A widget registers to listen to stores in its `initStores()` function. For example:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/view (widgets)/widgets

}
```

Once you’ve made this call, then flutter_flux will automatically call `setState()` to force the tree to rebuild. Alternatively, you can pass a lambda function to `listenToStore()` if you want to define another behavior when a store announces a change. The important point is that, by default, you do not need to define an event listener or call `setState()`.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who or what is making this call? "Once you've made this call" is hard to understand.


## Examples
1. **Where do I put View state, such as scroll positions?**
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why capitalize View here? Is it a formal concept or class?


In contrast, an `Animation<>` would almost never go in a `Store` because animations are usually tightly tied to the lifetime of the current widget tree.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But when would it go into a store?


## External Consumption
The library is unopinionated about how you organize your data and what you put in a Store. Practically speaking, with Stores delineated by entities, the change events broadcast by each store indicates that a set of entities has changed. Also, each store implements the business logic for a particular type of entity.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unopinionated? or, agnostic?

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.

2 participants