The Svelte context Map with the Redux entries added.
Only Entry in Context
If you don't need to add anything else to context:
import { provide } from "@laserware/sword";
import { mount } from "svelte";
import { createStore } from "./my-redux-store";
import App from "./App.svelte";
const store = createStore();
const app = mount(App, {
target: document.body,
context: provide(store),
});
export default app();
With Additional Context Entries
If you need to add other items to Svelte context, just use the return value
of provide
:
import { provide } from "@laserware/sword";
import { mount } from "svelte";
import { createStore } from "./my-redux-store";
import App from "./App.svelte";
const store = createStore();
// This is a Map<any, any>:
const context = provide(store);
context.set("extraItem", { foo: "bar" });
const app = mount(App, {
target: document.body,
context,
});
export default app();
Adds the specified Redux
store
to the specified Sveltecontext
.This is an alternative to wrapping your application's entry point in a
ProviderComponent
, which requires an extra component.