Skip to content

Instantly share code, notes, and snippets.

View eyaleizenberg's full-sized avatar

Eyal Eizenberg eyaleizenberg

View GitHub Profile
@eyaleizenberg
eyaleizenberg / episodes_length_selector.js
Created January 22, 2018 08:52
imdb_list custom selector
export const getEpisodesDataLength = (state) => state.superReducer.episodes.data.length;
@eyaleizenberg
eyaleizenberg / app_container.js
Created January 22, 2018 08:42
imdb_list final app container
import * as React from 'react';
import { connect } from 'react-redux'
import App from '../components/App/App';
import { selectors, actions } from '../redux/reducers';
import { fetchStrangerThings } from '../actions/episodesActions';
import PropTypes from 'prop-types';
export class AppContainer extends React.PureComponent {
static propTypes = {
showInfoVisible: PropTypes.bool.isRequired,
@eyaleizenberg
eyaleizenberg / episodesActions.js
Created January 22, 2018 08:36
imdb_list actions
import * as imdb from 'imdb-api';
import { actions } from '../redux/reducers';
const showId = 'tt4574334';
const apiKey = 'your_omdb_api_key_goes_here';
export const fetchStrangerThings = () => (dispatch) => {
imdb.getById(showId, { apiKey }).then(results => {
results.episodes().then(episodes => {
dispatch(actions.concatEpisodesData(episodes));
@eyaleizenberg
eyaleizenberg / app_container_with_action.js
Last active January 22, 2018 08:27
app container with actions
import { connect } from 'react-redux'
import { selectors, actions } from '../redux/reducers';
import App from '../components/App/App';
const mapStateToProps = (state) => ({
showInfoVisible: selectors.getShowInfoVisible(state)
});
const { toggleShowInfoVisible } = actions;
@eyaleizenberg
eyaleizenberg / appContainer_selectors.js
Last active January 22, 2018 08:28
App container for Redux Cornell
import { connect } from 'react-redux'
import { selectors } from '../redux/reducers';
import App from '../components/App/App';
const mapStateToProps = (state) => ({
showInfoVisible: selectors.getShowInfoVisible(state)
});
export default connect(mapStateToProps)(App);
@eyaleizenberg
eyaleizenberg / root_reducer.js
Last active March 20, 2018 06:17
Initializing Redux Cornell
import { combineReducers } from 'redux';
import reduxCornell from 'redux-cornell';
const { selectors, actions, superReducer } = reduxCornell({
initialState: {
episodes: {
loaded: false,
data: [],
expanded: {}
},
'use strict'
React = require('react-native')
NavigationBarRouteMapper = require('../modules/navigation_bar_route_mapper')
_ = require('lodash')
pages =
Incidents: Incidents
Notifications: Notifications