Skip to content

Instantly share code, notes, and snippets.

@einarlove
Last active March 14, 2017 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save einarlove/674b21f16a5cba4fadbbcaffaa92711b to your computer and use it in GitHub Desktop.
Save einarlove/674b21f16a5cba4fadbbcaffaa92711b to your computer and use it in GitHub Desktop.
React firebase deep subscriptions sketches
const createQuery = query => ({
[REACT_FIREBASE_QUERY_SYMBOL]: true,
query,
})
export default connect(props => ({
pathSubscription: 'path/to/data',
deepSubscription: {
a: {
aa: 'path/to/data/a/aa',
},
b: 'path/to/data/b',
},
aQuerySubscription: createQuery({
path: 'path/to/other/data',
orderByChild: 'order',
}),
}))(App)
connect(props => ({
game: `games/${props.id}`,
players: ({ game }) => mapValues(game.players, id => `players/${id}`)
}))(Game)
compose(
connect(props => ({
game: `games/${props.id}`,
}),
connect(props => ({
players: mapValues(props.game.players, id => `players/${id}`),
}),
)(Game)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment