🗡️
ConanJs
  • What is ConanJs?
  • Why ConanJs...
    • ... if coming from Redux
    • ... if using vanilla React
    • ... if learning React
    • ... if not using React
  • How to install/use ConanJs
  • About us / Github / Contact us
  • Demos
    • Demo Gallery
    • Conan State Demos
      • Hello World
      • Todos
        • Todos - Basic
        • Todos - Async
        • Todos - Optimistic
      • Github issues viewer
    • Conan Flow Demos
      • Authentication
  • CONAN DATA
    • General Concepts
    • Conan State
      • Actions & Reducers
        • Reducers
        • Actions
      • Creating State
      • Observing State
        • Live rendering
        • Connecting
      • Composing State
      • Scaling State
      • Orchestrating State
      • Life cycle
        • Async handling
        • Introspection
      • Testing state
    • Conan Flow
      • Creating Flows
      • Serialising Flows
      • Observing Flows
  • CONAN Runtime
  • Dependency Injection
    • General Concepts
    • Creating the Context
    • Using the Context
  • ASAPs
  • Logging
  • API
    • Main Classes
      • Conan
        • StateDef
      • ConanState
      • ConanFlow
        • UserFlowDef
        • UserStatusDef
        • Status
    • Conan State Classes
      • Thread
      • ConnectedState
      • MonitorInfo
      • MetaInfo
    • Dependency Injection
      • DiContextFactory
    • ASAPS
      • Asaps
      • Asap
Powered by GitBook
On this page
  • Introduction
  • Hooks
  • useFlow
  • useFlowStatus

Was this helpful?

  1. CONAN DATA
  2. Conan Flow

Observing Flows

PreviousSerialising FlowsNextDependency Injection

Last updated 4 years ago

Was this helpful?

Introduction

As described on the , you should be able to serialise a Flow to a ConanState that suits you, and then leverage all the features of the to observe it.

We have though some mechanisms to provide you with a shortcut when observing flows

As of v1.0 we only have hooks, but we are planning to add more shortcuts to observe directly flows without having to serialise them

Hooks

useFlow

useFlow<AuthenticationState,AuthenticationFlow>(
        authentication$F, 
        setState, 
        (status, previousState) => ({
                ...previousState,
                current: status.name,
        })
);

This hook receives

  • a flow

  • the method to set the state for this component

  • a function that returns the new state and that takes

    • the status information that has just been updated

    • the previous state

useFlowStatus

useFlowStatus<AuthenticationState, AuthenticationFlow,"authenticating">(
        authentication$F, 
        "authenticating", 
        setState, 
        (status, previousState) => ({
                ...previousState,
                currentUser: status[0]
         }
 ));

This hook receives

  • a flow

  • the name of the status to subscribe to

  • the method to set the state for this component

  • a function that returns the new state and that takes

    • the state information that has just been updated

    • the previous state

To see an example of hooks, check our demo

serialising flows
Conan State
Authentication