Skip to content

Instantly share code, notes, and snippets.

@iAmShakil
Last active August 31, 2018 17:33
Show Gist options
  • Save iAmShakil/9eff0b758a60b32cebef2898d962058c to your computer and use it in GitHub Desktop.
Save iAmShakil/9eff0b758a60b32cebef2898d962058c to your computer and use it in GitHub Desktop.

Revisions

  1. iAmShakil revised this gist Aug 31, 2018. 1 changed file with 0 additions and 5 deletions.
    5 changes: 0 additions & 5 deletions building-redux--step-3.js
    Original file line number Diff line number Diff line change
    @@ -16,20 +16,15 @@ function createStore(reducer){
    function getState(){
    return state
    }

    function dispatch(){

    }

    function subscribe(){

    // invoking this returned function will remove the subscriber function
    return function(){

    }

    }

    return {
    getState: getState,
    dispatch: dispatch,
  2. iAmShakil created this gist Aug 31, 2018.
    38 changes: 38 additions & 0 deletions building-redux--step-3.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    const reducer = ( state = 0, action ) => {
    switch(action.type){
    case "INCREMENT":
    return state + 1
    case "DECREMENT":
    return state - 1
    default:
    return state
    }
    }

    function createStore(reducer){
    // declaring the variable that holds state of the store
    var state

    function getState(){
    return state
    }

    function dispatch(){

    }

    function subscribe(){

    // invoking this returned function will remove the subscriber function
    return function(){

    }

    }

    return {
    getState: getState,
    dispatch: dispatch,
    subscribe: subscribe,
    }
    }