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 flip = () => ({ | |
flipResults: Math.random() | |
}) | |
// creation of headlesscomponent | |
class CoinFlip extends React.Component { | |
state = flip() | |
handleClick = () => this.setState(flip) | |
api() { |
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) |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
Usage: twilight.py [--city=<city> | --coordinates=<coordinates>] | |
[--date=<date> | --tomorrow] [--week] | |
[-h | --help | --version] | |
Options: | |
-h --help Show this help. | |
--version Show version. |
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
class ProjectType(graphql.DjangoModel): | |
class Meta: | |
model = Project | |
class ProjectSchema(graphql.DetailQuery, | |
graphql.ListQuery, | |
graphql.CreateMutation, | |
graphql.UpdateMutation, | |
graphql.DeleteMutation, |
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 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
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
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 } |