# Subscriptions: a misunderstanding or a bug?

**URL:** https://discourse.elm-lang.org/t/subscriptions-a-misunderstanding-or-a-bug/6826
**Category:** Learn
**Created:** [January 29, 2021, 10:11pm UTC](https://discourse.elm-lang.org/t/subscriptions-a-misunderstanding-or-a-bug/6826 "2021-01-29T22:11:48Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![jweir](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/jweir/32/447_2.png) [@jweir](https://discourse.elm-lang.org/u/jweir)
#### Post date: [January 29, 2021, 10:11pm UTC](https://discourse.elm-lang.org/t/subscriptions-a-misunderstanding-or-a-bug/6826/1 "2021-01-29T22:11:48Z")

</div>

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.

```auto
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.

```auto

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](https://ellie-app.com/ccVCwW7bL2Xa1)

So, is this a bug, or I am misunderstanding something about subscriptions?

---

<div class="post-metadata">

### Author: ![francescortiz](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/francescortiz/32/1721_2.png) [@francescortiz](https://discourse.elm-lang.org/u/francescortiz)
#### Post date: [January 30, 2021, 10:36am UTC](https://discourse.elm-lang.org/t/subscriptions-a-misunderstanding-or-a-bug/6826/2 "2021-01-30T10:36:55Z")

</div>

I don’t remember well, but I think it is a known bug. If that were true, you will have to find a workaround.

---

<div class="post-metadata">

### Author: ![antew](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/antew/32/2102_2.png) [@antew](https://discourse.elm-lang.org/u/antew)
#### Post date: [January 30, 2021, 3:50pm UTC](https://discourse.elm-lang.org/t/subscriptions-a-misunderstanding-or-a-bug/6826/3 "2021-01-30T15:50:45Z")

</div>

It sounds like locally you may have a older version of elm/core, there was a fix in 1.0.3 that should have addressed that issue, and might explain why it works in the Ellie (it is using 1.0.5).

Check out [Changes in subscriptions without effect if model changes in response to command from init · Issue #1776 · elm/compiler · GitHub](https://github.com/elm/compiler/issues/1776)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)
#### Post date: [February 9, 2021, 3:51pm UTC](https://discourse.elm-lang.org/t/subscriptions-a-misunderstanding-or-a-bug/6826/4 "2021-02-09T15:51:07Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
