This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { render } from 'react-dom' | |
-import { createStore } from 'redux' | |
+import { createStore, compose } from 'redux' | |
import { Provider } from 'react-redux' | |
import App from './components/App' | |
import reducer from './reducers' | |
import 'todomvc-app-css/index.css' | |
+import PouchDB from 'pouchdb' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { combineReducers } from 'redux' | |
import todos from './todos' | |
import visibilityFilter from './visibilityFilter' | |
+import { persistentReducer } from 'redux-pouchdb' | |
const rootReducer = combineReducers({ | |
todos, | |
visibilityFilter | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { combineReducers } from 'redux' | |
import todos from './todos' | |
import visibilityFilter from './visibilityFilter' | |
+import { withReduxStateSync } from 'redux-state-sync' | |
const rootReducer = combineReducers({ | |
todos, | |
visibilityFilter | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { render } from 'react-dom' | |
-import { createStore } from 'redux' | |
+import { createStore, applyMiddleware } from 'redux' | |
import { Provider } from 'react-redux' | |
import App from './components/App' | |
import reducer from './reducers' | |
import 'todomvc-app-css/index.css' | |
+import { createStateSyncMiddleware, initStateWithPrevTab } from 'redux-state-sync' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { render } from 'react-dom' | |
import { createStore } from 'redux' | |
import { Provider } from 'react-redux' | |
import App from './components/App' | |
import reducer from './reducers' | |
import 'todomvc-app-css/index.css' | |
+import { persistStore, persistReducer } from 'redux-persist' | |
+import { PersistGate } from 'redux-persist/integration/react' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { getStoredState, REHYDRATE } from 'redux-persist' | |
export default | |
function crossBrowserListener(store, persistConfig) { | |
return async function() { | |
let state = await getStoredState(persistConfig) | |
store.dispatch({ | |
type: REHYDRATE, | |
key: persistConfig.key, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { render } from 'react-dom' | |
-import { createStore } from 'redux' | |
+import { createStore, compose, applyMiddleware } from 'redux' | |
import { Provider } from 'react-redux' | |
import App from './components/App' | |
import reducer from './reducers' | |
import 'todomvc-app-css/index.css' | |
+import { storageMiddleware } from './middleware/storage' | |
+import { createStorageListener } from './utils/storage-listener' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function createStorageListener(store) { | |
return () => { | |
const wrappedAction = JSON.parse(localStorage.getItem(storageKey)) | |
delete wrappedAction.source | |
store.dispatch(wrappedAction) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const storageKey = 'redux-local-tab-sync' | |
export function storageMiddleware() { | |
return () => next => action => { | |
if (!action.source) { | |
const wrappedAction = Object.assign({ source: 'another tab' }, action) | |
localStorage.setItem(storageKey, JSON.stringify(wrappedAction)) | |
} | |
next(action) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, Inject, ViewContainerRef } from '@angular/core' | |
import { Service } from './service' | |
@Component({ | |
selector: 'my-app', | |
template: `<h1>Hello {{name}}</h1>` | |
}) | |
export class AppComponent { |
NewerOlder