- layout
- index.js
- [ComponentName]
- index.js
- ComponentName.js
- index.test.js
- index.mdx
- shared
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
| const getAsyncType = (type, status) => `${type}_${status}`; | |
| let index = 0; | |
| export const getMasterActionCreator = description => { | |
| const type = `${index++}__${description}`; | |
| const reqType = getAsyncType(type, "REQUEST"); | |
| const respType = getAsyncType(type, "SUCCESS"); | |
| const errType = getAsyncType(type, "ERROR"); |
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
| export const connect = selector => target => ({ children, ...props }) => { | |
| let updateFromParent = true; | |
| let cachedState = null; | |
| let cachedComponent = null; | |
| return ( | |
| <Consumer> | |
| {context => { | |
| const state = selector(context, props); | |
| if (!updateFromParent && (state === cachedState || shallowCompare(state, cachedState))) { | |
| updateFromParent = 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
| const store = { | |
| observedBits: { | |
| foo: 0b01, | |
| bar: 0b10 | |
| }, | |
| state: { | |
| foo: 1, | |
| bar: 1, | |
| }, | |
| update(cb) { |
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
| // workflow.js | |
| import { | |
| createReactCreator, | |
| child, | |
| // updateQueue is list of updates priority | |
| // `updateQueue` from `immutablePreset` have `compute` property | |
| // you must use it if you want change react own state before other reactions | |
| updateQueue | |
| } from "pathon/immutablePreset"; |
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
| const lib = require('../index'); | |
| // ------------------------------------ | |
| // -------------- HELPERS ------------- | |
| // ------------------------------------ | |
| const EFFECT_STATUS = { | |
| idle: 'IDLE', | |
| req: 'REQUEST', | |
| res: 'RESPONSE', |
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
| const createConcurrentRequest = () => { | |
| let lastReq; | |
| return async (request, ...params) => { | |
| let myReq = (lastReq = request(...params)); | |
| let response = null; | |
| let error = null; | |
| do { | |
| try { | |
| error = null; |
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
| /*[1]*/import {TextField} from 'material-ui' | |
| // TextField merge props for inner components (outer props and internal props) | |
| <TextField | |
| ownProps={ownProps} | |
| inputProps={{ style: { color: 'black' } }} | |
| placeholderProps={{ style: { color: 'gray' } }} | |
| /> | |
| // VS |
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
| // implicit cohesions | |
| root = store({ data: { list: [] }, loading: false, error: null }) | |
| .on(req, state => ({ ...state, error: null, loading: true })) | |
| .on(res, (state, list) => ({ ...state, data: { list }, loading: false })) | |
| .on(err, (state, error) => ({ ...state, error, loading: false })); | |
| // explicit cohesions | |
| export const data = store({ list: [] }) | |
| .on(res, list => ({ list })); |
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
| firstName$ = createCaller() | |
| lastName$ = createCaller() | |
| // not lazy | |
| fullName$ = combine( | |
| [firstName$, lastName$], | |
| (_, fn, ln) => [fn, ln].join(' ') | |
| ); | |
| displayName$ = combine( | |
| [firstName$, fullName$], | |
| (_, firstN, fullN) => firstN.length < 10 ? fullN : firstN |