Avoiding action chains

I am trying to understand the Flux pattern.

I believe that in any good design, the application should consist of relatively independent and universal (and, therefore, reusable) components glued together using specific application logic.

Flux has domain-specific storages that encapsulate data and domain logic. They can be reused in another application for the same domain.

I assume that there should also be application-specific application repositories and application state. This is glue.

Now I'm trying to apply this to an imaginary GPS Tracker application:

...

When the user clicks the [Stop Tracking] button, the corresponding ViewController raises STOP_CLICK.

  • AppState.on(STOP_CLICK):

    • dispatch(STOP_GEOLOCATION)
    • dispatch(STOP_TRACKING)
  • GeolocationService.on(STOP_GEOLOCATION):

    • stopGPS(); this.on = false; emit('change')
  • TrackStore.on(STOP_TRACKING):

    • saveTrack(); calcStatistics(); this.tracking = false; emit('change')
    • dispatch(START_UPLOAD)

So I have a snowball.

, Flux . , .

, , UI-. AppState ( , ) .

  • Flux?
  • ?
  • ?
  • ""?

.

+4
1

. , - , .

. - , , .

. . , : , ..

:

(STOP_GEOLOCATION)

(STOP_TRACKING)

, : STOP_TRACKING_BUTTON_CLICKED ( TRACKING_STOPPED, UI). , . , , . , , .

, , , , , .

+4

All Articles