You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
chee rabbits 9f914114c2 fix jquery code style 1 year ago
README.md fix jquery code style 1 year ago
jquery.redux.js fix jquery code style 1 year ago
jquery.redux.min.js Initial commit 1 year ago

README.md

⚠ DEPRECATED ⚠

jquery.redux

$element can have little a reducer, as a treat

usage

setup

<script src="https://git.snoot.club/chee/jquery.redux/raw/master/jquery.redux.min.js">

Note! Make sure to include it after jquery!!

set-reducer

var initialState = 0;

function reducer( state, action ) {
  state = state || initialState
  switch( action.type ) {
    case "+":
      return state + 1
    case "-":
      return state - 1
    case "@jQuery/init":
      return 0
    default:
      return state;
  }
}

$( "#my-element" ).redux( "set-reducer", { reducer } );

dispatch

$("#my-element")
    .redux("dispatch", {
	    action: {
		    type: "+"
	    }
	})
    .redux("dispatch", {
	    action: {
		    type: "+"
	    }
	})

get-state

$( "#my-element" ).redux( "get-state" ); //=> 2