Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

store.compute in oncreate data not loading initial value #223

Closed
btakita opened this issue Mar 31, 2018 · 2 comments
Closed

store.compute in oncreate data not loading initial value #223

btakita opened this issue Mar 31, 2018 · 2 comments

Comments

@btakita
Copy link
Contributor

btakita commented Mar 31, 2018

<div class="Message">
  <header>{{$message_header}}</header>
</div>

<script>
  export default {
    oncreate() {
      this.store({person: {name: 'John Smith'}))
      this.store.compute('message_header', ['person'], person => (person && person.name) || '')
    }
  }
</script>

The first rendered value of $message_header will be ''. Any subsequent changes to person in the store will show up in the UI.

Something that causes the initial render to occur is to set message_header in the store before compute('message_header', ...)

      this.store.set({message_header: (person && person.name) || ''})
      this.store.compute('message_header', ['person'], person => (person && person.name) || '')
@Rich-Harris
Copy link
Member

Is this the same bug that was recently fixed in Svelte itself?

@btakita
Copy link
Contributor Author

btakita commented May 5, 2018

Yes it is the same issue as sveltejs/svelte#1327

@btakita btakita closed this as completed May 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants