Skip to content

Instantly share code, notes, and snippets.

@ispyinternet
Created November 25, 2017 21:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ispyinternet/23232f601a73e63e6fe19ce2fd50286d to your computer and use it in GitHub Desktop.
Save ispyinternet/23232f601a73e63e6fe19ce2fd50286d to your computer and use it in GitHub Desktop.
<!-- 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