Function useStore

  • Gets the Redux store from Svelte context. Note that you should normally not need to use this unless you need to call replaceReducer or perform some other operation that requires access to the entire store.

    Type Parameters

    • S

      Redux state definition.

    Returns Store<S>

    The Redux store from Svelte context.

    <script>
    import { useStore } from "@laserware/sword";

    import { someAction } from "./my-redux-actions";

    const store = useStore();

    function handleClick() {
    console.log(store.getState()); // Returns state

    store.dispatch(someAction());
    }
    </script>

    <button onclick={handleClick}>Click Me</button>