Skip to content

FluxComponent Subscriptions

Shane Brinkman-Davis edited this page Jan 2, 2017 · 3 revisions

Declaring a subscription on a FluxComponent has a few important effects. For a given subscription with a state-field name 'myStatefield':

  • defines the getter: @myStatefield
  • sets multiple fields on @state:
    • @state.myStateField - the current value from the subscription or null if no value has been fetched
    • @state.myStateFieldStatus - (string) the current status of fetching the value for the subscription (see Art.Founcation.ConnectionStatus)
    • @state.myStateFieldProgress - (number between 0 and 1) the current progress fetching the value for the subscription

Example

class UserView extends FluxComponent
  @subscriptions "user"

  render: ->
    TextElement
      text: @user?.name || @state.userStatus
          

Clone this wiki locally