<|start_filename|>demo-web/rollup.config.js<|end_filename|>
const babel = require('rollup-plugin-babel');
const resolve = require('rollup-plugin-node-resolve');

process.env.NODE_ENV = 'development';

module.exports = {
    input: './src/index.js',
    output: {
        file: `${__dirname}/bundle.js`,
        format: 'iife',
        exports: 'named',
        globals: {
            'react': 'React',
            'react-dom': 'ReactDOM',
            'redux': 'Redux',
            'react-redux': 'ReactRedux',
            'redux-remember': 'ReduxRemember'
        }
    },
    plugins: [
        resolve(),
        babel({
            runtimeHelpers: true,
            exclude: 'node_modules/**'
        })
    ],
    external: [
        'react',
        'react-dom',
        'redux',
        'react-redux',
        'redux-remember'
    ]
};


<|start_filename|>demo-web/src/app.js<|end_filename|>
import React from 'react';
import { connect } from 'react-redux';
import { setText1, setText2 } from './store/actions';

const App = ({
  textToBePersisted = '',
  textToBeForgotten = '',
  setText1,
  setText2
}) => (
  <div>
    <h1>redux-remember demo (uses window.localStorage)</h1>
    <h2>Type something into the inputs and reload the page</h2>

    <div>
      <label>I shall be remembered :)</label>
    </div>

    <div>
      <input
        type="text"
        value={textToBePersisted}
        onChange={ev => setText1(ev.target.value)}
      />
    </div>

    <div>
      <label>I shall be forgotten :(</label>
    </div>

    <div>
      <input
        type="text"
        value={textToBeForgotten}
        onChange={ev => setText2(ev.target.value)}
      />
    </div>

    <div className="source-code">
      <a
        href="https://github.com/zewish/redux-remember/tree/master/demo-web/src"
        target="_blank"
        rel="noopener noreferrer nofollow"
      >
        [ See demo source ]
      </a>
    </div>
  </div>
);

export default connect(
  ({ textToBePersisted, textToBeForgotten }) => ({
    textToBePersisted, textToBeForgotten
  }),
  dispatch => ({
    setText1: text => dispatch(
      setText1(text)
    ),
    setText2: text => dispatch(
      setText2(text)
    )
  })
)(App);


<|start_filename|>demo-web/bundle.js<|end_filename|>
(function (React, reactDom, reactRedux, redux, reduxRemember) {
    'use strict';

    React = React && React.hasOwnProperty('default') ? React['default'] : React;

    var SET_TEXT1 = 'SET_TEXT1';
    var SET_TEXT2 = 'SET_TEXT2';
    var setText1 = function setText1(text) {
      return {
        type: SET_TEXT1,
        payload: text
      };
    };
    var setText2 = function setText2(text) {
      return {
        type: SET_TEXT2,
        payload: text
      };
    };

    var textToBePersisted = function textToBePersisted() {
      var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';

      var _ref = arguments.length > 1 ? arguments[1] : undefined,
          type = _ref.type,
          payload = _ref.payload;

      switch (type) {
        case SET_TEXT1:
          return payload;

        default:
          return state;
      }
    };

    var textToBeForgotten = function textToBeForgotten() {
      var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';

      var _ref2 = arguments.length > 1 ? arguments[1] : undefined,
          type = _ref2.type,
          payload = _ref2.payload;

      switch (type) {
        case SET_TEXT2:
          return payload;

        default:
          return state;
      }
    };

    var reducers = {
      textToBePersisted: textToBePersisted,
      textToBeForgotten: textToBeForgotten,
      someData: function someData() {
        var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'bla';
        return state;
      }
    };

    var rememberedKeys = ['textToBePersisted'];
    var store = redux.createStore(reduxRemember.rememberReducer(redux.combineReducers(reducers)), redux.compose(redux.applyMiddleware(), reduxRemember.rememberEnhancer(window.localStorage, rememberedKeys, {
      persistWholeStore: true
    })));

    var _jsxFileName = "/Users/wish/Desktop/redux-remember/demo-web/src/app.js";

    var App = function App(_ref) {
      var _ref$textToBePersiste = _ref.textToBePersisted,
          textToBePersisted = _ref$textToBePersiste === void 0 ? '' : _ref$textToBePersiste,
          _ref$textToBeForgotte = _ref.textToBeForgotten,
          textToBeForgotten = _ref$textToBeForgotte === void 0 ? '' : _ref$textToBeForgotte,
          setText1 = _ref.setText1,
          setText2 = _ref.setText2;
      return React.createElement("div", {
        __source: {
          fileName: _jsxFileName,
          lineNumber: 11
        },
        __self: this
      }, React.createElement("h1", {
        __source: {
          fileName: _jsxFileName,
          lineNumber: 12
        },
        __self: this
      }, "redux-remember demo (uses window.localStorage)"), React.createElement("h2", {
        __source: {
          fileName: _jsxFileName,
          lineNumber: 13
        },
        __self: this
      }, "Type something into the inputs and reload the page"), React.createElement("div", {
        __source: {
          fileName: _jsxFileName,
          lineNumber: 15
        },
        __self: this
      }, React.createElement("label", {
        __source: {
          fileName: _jsxFileName,
          lineNumber: 16
        },
        __self: this
      }, "I shall be remembered :)")), React.createElement("div", {
        __source: {
          fileName: _jsxFileName,
          lineNumber: 19
        },
        __self: this
      }, React.createElement("input", {
        type: "text",
        value: textToBePersisted,
        onChange: function onChange(ev) {
          return setText1(ev.target.value);
        },
        __source: {
          fileName: _jsxFileName,
          lineNumber: 20
        },
        __self: this
      })), React.createElement("div", {
        __source: {
          fileName: _jsxFileName,
          lineNumber: 27
        },
        __self: this
      }, React.createElement("label", {
        __source: {
          fileName: _jsxFileName,
          lineNumber: 28
        },
        __self: this
      }, "I shall be forgotten :(")), React.createElement("div", {
        __source: {
          fileName: _jsxFileName,
          lineNumber: 31
        },
        __self: this
      }, React.createElement("input", {
        type: "text",
        value: textToBeForgotten,
        onChange: function onChange(ev) {
          return setText2(ev.target.value);
        },
        __source: {
          fileName: _jsxFileName,
          lineNumber: 32
        },
        __self: this
      })), React.createElement("div", {
        className: "source-code",
        __source: {
          fileName: _jsxFileName,
          lineNumber: 39
        },
        __self: this
      }, React.createElement("a", {
        href: "https://github.com/zewish/redux-remember/tree/master/demo-web/src",
        target: "_blank",
        rel: "noopener noreferrer nofollow",
        __source: {
          fileName: _jsxFileName,
          lineNumber: 40
        },
        __self: this
      }, "[ See demo source ]")));
    };

    var App$1 = reactRedux.connect(function (_ref2) {
      var textToBePersisted = _ref2.textToBePersisted,
          textToBeForgotten = _ref2.textToBeForgotten;
      return {
        textToBePersisted: textToBePersisted,
        textToBeForgotten: textToBeForgotten
      };
    }, function (dispatch) {
      return {
        setText1: function setText1$1(text) {
          return dispatch(setText1(text));
        },
        setText2: function setText2$1(text) {
          return dispatch(setText2(text));
        }
      };
    })(App);

    var _jsxFileName$1 = "/Users/wish/Desktop/redux-remember/demo-web/src/index.js";
    reactDom.render(React.createElement(reactRedux.Provider, {
      store: store,
      __source: {
        fileName: _jsxFileName$1,
        lineNumber: 9
      },
      __self: undefined
    }, React.createElement(App$1, {
      __source: {
        fileName: _jsxFileName$1,
        lineNumber: 10
      },
      __self: undefined
    })), document.getElementById('root'));

}(React, ReactDOM, ReactRedux, Redux, ReduxRemember));


<|start_filename|>demo-web/src/store/index.js<|end_filename|>
import { createStore, combineReducers, compose, applyMiddleware } from 'redux';
import reducers from './reducers';
import { rememberReducer, rememberEnhancer } from 'redux-remember';

const rememberedKeys = [ 'textToBePersisted' ];

const store = createStore(
  rememberReducer(
      combineReducers(reducers)
  ),
  compose(
    applyMiddleware(
      // ...
    ),
    rememberEnhancer(
      window.localStorage,
      rememberedKeys,
      { persistWholeStore: true }
    )
  )
);

export default store;


<|start_filename|>rollup.config.js<|end_filename|>
import ts from '@wessberg/rollup-plugin-ts';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';

export default {
  input: './src/index.ts',
  output: {
    name: 'ReduxRemember',
    exports: 'named',
    sourcemap: true,
    interop: false,
    strict: false
  },
  external: ['redux'],
  plugins: [
    resolve({
      mainFields: [
        'module',
        'jsnext:main',
        'main'
      ]
    }),
    commonjs(),
    ts({
      transpiler: 'babel',
      babelConfig: `${__dirname}/.babelrc`,
      hook: {
        outputPath(path, kind) {
          if (kind === 'declaration') {
            return `${__dirname}/index.d.ts`;
          }

          return path;
        }
      }
    })
  ]
};


<|start_filename|>demo-web/src/store/reducers.js<|end_filename|>
import { SET_TEXT1, SET_TEXT2 } from './actions';

const textToBePersisted = (state = '', { type, payload }) => {
  switch (type) {
    case SET_TEXT1:
      return payload;

    default:
      return state;
  }
};

const textToBeForgotten = (state = '', { type, payload }) => {
  switch (type) {
    case SET_TEXT2:
      return payload;

    default:
      return state;
  }
};

export default {
  textToBePersisted,
  textToBeForgotten,
  someData: (state = 'bla') => state
};


<|start_filename|>demo-web/src/store/actions.js<|end_filename|>
export const SET_TEXT1 = 'SET_TEXT1';
export const SET_TEXT2 = 'SET_TEXT2';

export const setText1 = (text) => ({
  type: SET_TEXT1,
  payload: text
});

export const setText2 = (text) => ({
  type: SET_TEXT2,
  payload: text
});
