1.4.1 • Published 9 months ago

svelte-reduxify v1.4.1

Weekly downloads
67
License
ISC
Repository
github
Last release
9 months ago

svelte-reduxify

connect your svelte store to redux devtools with minimal code change

Installation

npm install svelte-reduxify

Usage

import { reduxify } from "svelte-reduxify";
const store = reduxify(writable(0));

Full example

Original code

import { writable } from 'svelte/store';

function createCount() {
  const { subscribe, set, update } = writable(0);

  return {
    subscribe,
    increment: () => update(n => n + 1),
    decrement: () => update(n => n - 1),
    reset: () => set(0)
  };
}

export const count = createCount();

Modified code

import { writable } from 'svelte/store';
import { reduxify } from "svelte-reduxify";

function createCount() {
  const { subscribe, set, update } = writable(0);

  return reduxify({
    update, // necessary for updating state from devtools
    subscribe,
    increment: () => update(n => n + 1),
    decrement: () => update(n => n - 1),
    reset: () => set(0)
  });
}

export const count = createCount();

Comparison

  import { writable } from 'svelte/store';
+ import { reduxify } from "svelte-reduxify";
  
  function createCount() {
    const {subscribe, set, update } = writable(0);
 
-   return { 
+   return reduxify({
+     update, // necessary for updating state from devtools
      subscribe,
      increment: () => update(n => n + 1),
      decrement: () => update(n => n - 1),
      reset: () => set(0)
-   }
+   });
  }
  
  export const count = createCount();

Redux DevTools

View actions

Redux DevTools
You can "Jump" to states and use the timeline slider

Dispatch actions and states

You can dispatch an action by name
Dispatch Actions
You can also dispatch state in JSON format
Dispatch States

1.4.1

9 months ago

1.4.0

1 year ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.0

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago