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
{ | |
"Edit": { | |
"translation": "Upravit", | |
"origin": [ | |
[ | |
"src/lingui/projects/scenes/Repository/ui/EditableDescription.js", | |
81 | |
] | |
] | |
}, |
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
// load() call is removed, but import remains there | |
!function(modules) { | |
function __webpack_require__(moduleId) { | |
if (installedModules[moduleId]) return installedModules[moduleId].exports; | |
var module = installedModules[moduleId] = { | |
i: moduleId, | |
l: !1, | |
exports: {} | |
}; |
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
// Just an example of `isAuthenticated` selector | |
const selector = { | |
isAuthenticated: state => state.auth.isAuthenticated | |
} | |
export const authRequired = (saga) => function* (action) { | |
const isAuthenticated = yield select(selector.isAuthenticated) | |
// If user isn't authenticated, redirect him to /login | |
if (!isAuthenticated) { |
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
export const fetchSaga = (entity, api) => function* ({ payload }) { | |
try { | |
const data = yield call(api, payload) | |
yield put(entity.response(data)) | |
} | |
catch(error) { | |
// When there's error.response, it's usually response from | |
// backend server with status 4xx or 5xx. | |
// No response mostly means there's a connection error, because | |
// we don't even get anything from server. |
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
export function* checkConnection () { | |
let interval = 1 | |
// eslint-disable-next-line no-constant-condition | |
while (true) { | |
// race == wait for effect which comes first | |
const { timeout, up } = yield race({ | |
// ping triggered manually | |
// e.g: 'reconnect now' button | |
ping: take(action.networkPing), |
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
function ApiGetUser({ id }) { | |
return fetch(url`/user/${id}`) | |
} | |
// Just an example. Action creators are usually | |
// created using `createAction` from `redux-actions` | |
const getUser = { | |
request: (id) => ({ | |
type: 'USER_GET@REQUEST', | |
payload: { id } |
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
export const fetchSaga = (entity, api) => function* ({ payload }) { | |
try { | |
const data = yield call(api, payload) | |
yield put(entity.response(data)) | |
} | |
catch(error) { | |
yield put(entity.response(error)) | |
} | |
} |
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
module Y2017.M06.D07.Exercise where | |
{-- | |
So, here's one of the questions Amazon asks developers to test their under- | |
standing of data structures. | |
You have a binary tree of the following structure: | |
A | |
/ \ |
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 reducer = ... | |
const ID = 'auth' | |
const local = state => state[ID] | |
const getUser = state => local(state).user | |
const isAuthenticated = state => Boolean(getUser(state)) | |
export default {[ID]: reducer} |
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 initialState = { | |
user: { | |
name: 'anonymous', | |
token: null | |
} | |
} | |
const getUser = state => state.user || {} | |
const isAuthenticated = state => Boolean(getUser(state).token) | |
const isAnonymous = state => !isAuthenticated(user) |