Skip to content

Hot Module Reloading does not retain state in services #369

Description

@timkindberg

With Hot Module Reloading I was expecting that only the file/component that I made a change to would be swapped out. However, if you have a service injected into the changed component that is holding some state, that state is refreshed to it's beginning state again.

Setup:
ServiceA has a data property that starts as 'foo'
ComponentA injects ServiceA as public
ComponentA.template = <h1>{{serviceA.data}}</h1><button (click)="serviceA.data = 'bar' ">Click</button>;
ComponentA button click changes 'data' to 'bar'.

Steps:
Launch app
Click button
Make an edit to ComponentA

Actual:
h1 shows 'foo'

Expected:
h1 to show 'bar'

Activity

  1. PatrickJS commented on Mar 13, 2016

    @PatrickJS
    Owner

    I didn't create proxies for any of the components or service because the implementation is a simple one since there are many core changes planned I didn't want to create one only to refactor it many times over. I'm closing this for now to keep the issues down

  2. samuel-kollat commented on Mar 15, 2016

    @samuel-kollat

    Could you point me in the right direction how to hold state in components/services with HMR and also how not to reload whole page/state after CSS (Sass) file update ?

  3. PatrickJS commented on Mar 15, 2016

    @PatrickJS
    Owner

    I this working now I just need to push it up later

  4. PatrickJS commented on Mar 30, 2016

    @PatrickJS
    Owner

    if you use npm start:hmr you will have HMR with state management using a decorator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions