Skip to content

Update README.md - #1

Open
jimbeveridge wants to merge 1 commit into
masterfrom
readme
Open

jimbeveridge wants to merge 1 commit into
masterfrom
readme

Conversation

@jimbeveridge

Copy link
Copy Markdown
Owner

No description provided.

Comment thread README.md
# 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
Copy Markdown

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.

Comment thread README.md
# 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
Copy Markdown

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.

Comment thread README.md
## Motivation

![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
Copy Markdown

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.

Comment thread README.md

`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
Copy Markdown

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)

Comment thread README.md
## Design

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

Copy link
Copy Markdown

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)

Comment thread README.md
```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
Copy Markdown

Choose a reason for hiding this comment

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

s/view (widgets)/widgets

Comment thread README.md
}
```

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
Copy Markdown

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.

Comment thread README.md
## **FAQs**

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

Copy link
Copy Markdown

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?

Comment thread README.md
includes instructions for building / running them.
The decision is based on whether the view state information needs to outlive the widget hierarchy, which is torn down whenever your route is changed, which causes all `State` in a `StatefulWidget` to be lost. For example, If you want the scroll position to be restored the next time the route is displayed, then scroll position should be in a Store, not a StatefulWidget.

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
Copy Markdown

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?

Comment thread README.md
1. **Can I just put everything into a single 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
Copy Markdown

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