3.0.1 • Published 9 months ago

@laserware/sword v3.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@laserware/sword

Svelte wrapper over Redux.

Usage

Install the dependency. Note that svelte is required as a peer dependency:

npm install @laserware/sword @laserware/stasis svelte

Wrap your Svelte entry point component with <Provider>:

// src/main.ts
import { Provider } from "@laserware/sword";
import { mount } from "svelte";

import App from "./App.svelte";

const app = mount(App, { target: document.body });

export default app();
<!-- App.svelte -->
<script lang="ts">
  import { Provider } from "@laserware/sword";

  import { createStore } from "./my-redux-store";

  import MyComponent from "./MyComponent.svelte"

  const store = createStore();
</script>

<Provider {store}>
  <MyComponent />
</Provider>

Import the useDispatch or useSelect functions in components that need to dispatch Redux actions or access Redux state:

<!-- MyComponent.svelte -->
<script lang="ts">
  import { useDispatch, useSelector } from "@laserware/sword";

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

  const dispatch = useDispatch();

  const someValue = useSelector(selectSomeValue);

  function handleClick(): void {
    dispatch(someAction(someValue.value));
  }
</script>

<button on:click={handleClick}>Click me</button>
3.0.1

9 months ago

3.0.0-beta.1

11 months ago

3.0.0-beta.0

11 months ago

3.0.0-beta.3

11 months ago

3.0.0-beta.2

11 months ago

3.0.0

11 months ago

2.3.0

11 months ago

1.3.1

1 year ago

1.3.0

1 year ago

2.2.0

1 year ago

2.1.2

1 year ago

2.1.1

1 year ago

2.1.3

1 year ago

2.1.5

1 year ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago