I created an application were subscriptions were not firing when running the app in Reactor or compiled. The app does work as expected in Ellie.
type Model
= Empty
| Running Time.Posix
A Model starts Empty and becomes Running after a Task is performed. After
becoming Running the Running subscriptions branch is called but the subscription is not run – not until another event is fired such as click event.
init : () -> ( Model, Cmd Msg )
init _ =
( Empty, Task.perform Tick Time.now )
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
Noop ->
( model, Cmd.none )
Tick t ->
( Running t, Cmd.none )
subscriptions : Model -> Sub Msg
subscriptions model =
case model of
Empty ->
Sub.none
Running _ ->
Time.every 100 Tick
This is the behaviour at least on MacOS Chrome and Safari running the code through Reactor or a complied index.html
.
But the behaviour in Ellie is what I would expect when the Running
subscriptions branch is reached after initialization.
Here is the code running in Ellie
https://ellie-app.com/ccVCwW7bL2Xa1
So, is this a bug, or I am misunderstanding something about subscriptions?