0.1.2 • Published 4 years ago

ractive-rematch v0.1.2

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

ractive-rematch

redux connector for ractivejs application, with rematch as redux api provider.

Get Started

Install dependencies

$ yarn add @rematch/core ractive-rematach

Initialize store binding

import Ractive from "ractive";
import { init } from "@rematch/core";
import { bindStore } from "ractive-rematch";
import models from "./models"

bindStore(init({models}));

const applicationContainerDOMElement = document.querySelector("#root");

const instance = new Ractive({
  el:applicationContainerDOMElement,
  template:`<span>{variable}</span>`,
  data:{
    variable:12
  }
})

const Component = Ractive.extend({
  data:{
    variable:13
  }
})

const mapStateToData = state => ({
  name: state.userInfo.name,
  age: state.userInfo.age
})

const mapDispatchToMethod = dispatch => ({
  changeName(name){
    dispatch.userInfo.changeName(name)
  }
})

/* 
 * the dispatch function will be attached to instance. 
 */
connectInstance(mapStateToData,mapDispatchToMethod)(instance)

// Connect state to a subclass instead of instance please use `connect`
connect(mapStateToData,mapDispatchToMethod)(Component)
0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago