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
//@flow | |
import firebase from '../firebase' | |
export function listenRequested(metaType: string) { | |
return { | |
type: 'FIREBASE_LISTEN_REQUESTED', | |
metaType, | |
} | |
} |
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
//@flow | |
import createReducer from '../createReducer' | |
export const metaTypes = { | |
messages: 'messages', | |
userContacts: 'userContacts', | |
} | |
function getInitialState() { |
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
//@flow | |
import firebase from '../firebase' | |
export function listenRequested(metaType: string) { | |
return { | |
type: 'FIREBASE_LISTEN_REQUESTED', | |
metaType | |
} | |
} |
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
//@flow | |
import createReducer from '../createReducer' | |
export const metaTypes = { | |
messages: 'messages', | |
userContacts: 'userContacts', | |
} | |
function getInitialState() { |
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
//@flow | |
export function listenRequested(metaType: string, ref: Object) { | |
return { | |
type: 'FIREBASE_LISTEN_REQUESTED', | |
metaType, | |
ref | |
} | |
} |
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 ref = firebase.database().ref(path) | |
dispatch(listenRequested(metaType, ref)) |
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
//@flow | |
import firebase from '../firebase' | |
export function messagesRequested() { | |
return { | |
type: 'MESSAGES_REQUESTED' | |
} | |
} |
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
//@flow | |
import createReducer from '../createReducer' | |
const initialState = { messages: { inProgress: false, items: { } } } | |
//createReducer taken from here http://redux.js.org/docs/recipes/ReducingBoilerplate.html | |
export const reducer = createReducer(initialState, { | |
['MESSAGES_REQUESTED'](state, action) { | |
const newState = { ...state, |
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
//@flow | |
export function listenRemoved(metaType: string) { | |
return { | |
type: 'FIREBASE_LISTEN_REMOVED', | |
metaType, | |
} | |
} |
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
['FIREBASE_LISTEN_REQUESTED'](state, action) { | |
const newState = { | |
...state, | |
[action.metaType]: { | |
...state[action.metaType], | |
inProgress: true, error: '', ref: action.ref | |
} | |
} | |
return newState | |
}, |
OlderNewer