This file contains hidden or 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
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
This file contains hidden or 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
beforeEach(() => { | |
Mockdate.set('2021-06-27T21:32:09.419Z'); | |
}); | |
afterEach(() => { | |
Mockdate.reset(); | |
}); |
This file contains hidden or 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, { useState, useEffect } from "react"; | |
import { AccessibilityInfo, View, Text } from "react-native"; | |
import Animated from "react-native-reanimated"; | |
const { block, cond, eq, useCode } = Animated; | |
const App = () => { | |
const [reduceMotionEnabled, setReduceMotionEnabled] = useState(false); | |
useEffect(() => { |
This file contains hidden or 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
// todos.js | |
import { createSlice } from '@reduxjs/toolkit' | |
const todosSlice = createSlice({ | |
name: 'todos', | |
initialState: [], | |
reducers: { | |
addTodo(state, action) { | |
const { id, text } = action.payload | |
state.push({ id, text, completed: false }) |
This file contains hidden or 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 { createSlice, configureStore } from '@reduxjs/toolkit' | |
const todosSlice = createSlice({ | |
name: 'todos', | |
initialState: [], | |
reducers: { | |
addTodo(state, action) { | |
const { id, text } = action.payload | |
state.push({ id, text, completed: false }) | |
}, |
This file contains hidden or 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 { createStore, combineReducers } from 'redux' | |
import { authentication, todos } from './reducers' | |
const rootReducer = combineReducers({ | |
authentication, | |
todos | |
}) | |
const store = createStore(rootReducer) |
This file contains hidden or 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 { createAction, createReducer, configureStore } from '@reduxjs/toolkit' | |
const addTodo = createAction('ADD_TODO') | |
const toggleTodo = createAction('TOGGLE_TODO') | |
const todos = createReducer([], { | |
[addTodo]: (state, action) => { | |
const todo = action.payload | |
return [...state, todo] | |
}, |
This file contains hidden or 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 { createAction, createReducer, configureStore } from '@reduxjs/toolkit' | |
const addTodo = createAction('ADD_TODO') | |
const toggleTodo = createAction('TOGGLE_TODO') | |
const todos = createReducer([], { | |
[addTodo]: (state, action) => { | |
const { id, text } = action.payload | |
state.push({ id, text, completed: false }) | |
}, |
This file contains hidden or 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 { createAction, createReducer, configureStore } from '@reduxjs/toolkit' | |
const increment = createAction('INCREMENT') | |
const decrement = createAction('DECREMENT') | |
const counter = createReducer(0, { | |
[increment]: state => state + 1, | |
[decrement]: state => state - 1 | |
}) |