Skip to content

Instantly share code, notes, and snippets.

View factoryhr's full-sized avatar

Factory.dev factoryhr

View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:overScrollMode="never">
<RelativeLayout
android:id="@+id/rlProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:overScrollMode="never">
<RelativeLayout
android:id="@+id/rlProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
function createStore(reducer, preloadedState) {
if (typeof reducer !== 'function') {
throw new Error('Expected `reducer` to be a function.');
}
if (typeof preloadedState === 'function') {
console.warn(
'Received function as `preloadedState`. ' +
'State is undefined.'
);
function createStore(reducer, preloadedState) {
var currentState = preloadedState;
var listeners = [];
function getState() {
return currentState;
}
function subscribe(listener) {
listeners.push(listener);
function createStore(reducer, preloadedState) {
var currentState = preloadedState;
// Keep track of all listeners
var listeners = [];
function getState() {
return currentState;
}
// Subscribe new listeners to the store
function createStore(reducer, preloadedState) {
// Store the current state
var currentState = preloadedState;
// Retrieve the current state
function getState() {
return currentState;
}
// Expose the API
function createStore(reducer, preloadedState) {
// Our store implementation will go here...
}
function counterReducer(state, action) {
switch (action.type) {
case actionTypes.increment:
return incrementHandler(state, action);
case actionTypes.decrement:
return decrementHandler(state, action);
default:
return state;
}
}
function incrementHandler(state, action) {
var nextState = Object.assign({}, state);
nextState.counter += 1;
return nextState;
}
function decrementHandler(state, action) {
var nextState = Object.assign({}, state);
nextState.counter -= 1;
return nextState;