Created
November 25, 2017 21:11
-
-
Save ispyinternet/23232f601a73e63e6fe19ce2fd50286d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- App.html --> | |
<h1>Hello {{$name}}!</h1> | |
<Foo/> | |
<script> | |
import Foo from './Foo.html'; | |
export default { | |
components: { NameInput } | |
}; | |
</script> | |
<!-- Foo.html --> | |
<input placeholder='Enter your name' bind:value='{{$name}}' on:input='store.setName(this.value)'> | |
<script> | |
import { Store, combineStores } from 'svelte/store.js'; | |
class FooStore extends Store { | |
setName(name) { | |
this.set({ name }); | |
} | |
} | |
export default { | |
// whatever | |
oncreate() { | |
// FooStore exposes itself to the rest of the app? | |
combineStores({ | |
foo: new FooStore({ myLocalValue: 42 }) | |
}, this.store); | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment