Skip to content

@cycle/state ignores write effects until you've actually read from the source #938

@monojack

Description

@monojack

As the title says, you have to read from the state.stream before sending any write effects otherwise they will be ignored. This is a problem when you have a transition view (like a splash screen component) that doesn't read from the state source and the write effects are sent during that splash screen.

I have a splash screen during which (amongst other things like preloading some resources) I try to auth by verifying some token from the localStorage and then store the authentication result (user data) in the state (along with some other information like what is the next "route" - based on the auth result).
The initial reducer is in the wrapper main function, so that doesn't do anything either. So unless I read from state.stream in the main function, I'm stuck.

Changing the reducerMimic$ to a MemoryStream would make it work

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions