Update README.md

This commit is contained in:
Artem Zakharchenko
2017-06-30 10:40:36 +02:00
committed by GitHub
parent c8133142a2
commit aace01b182

View File

@ -28,10 +28,17 @@ class MenuItem {
``` ```
## Methods ## Methods
**Pattern:** ### Pattern
``` ```
prefix? + action + high context (HC) + low context (LC) prefix? + action (A) + high context (HC) + low context (LC)
``` ```
#### Example
| Name | Prefix | Action | High context | Low context |
| ---- | ---- | ------ | ------------ | ----------- |
| `getPost` | | `get` | `Post` | |
| `getPostData` | | `get` | `Post` | `Data` |
| `handleClickOutside` | | `handle` | `Click` | `Outside` |
| `shouldComponentUpdate` | `should` | `Component` | `Update`| |
### Actions ### Actions
#### `get` #### `get`
@ -42,14 +49,14 @@ function getFruitsCount() {
} }
``` ```
#### `fetch` #### `fetch`
Request for variable/data, which takes time (i.e. async request). Request for data, which takes time (i.e. async request).
```js ```js
function fetchPosts(postCount) { function fetchPosts(postCount) {
return fetch('https://api.dev/posts', { ... }); return fetch('https://api.dev/posts', { ... });
} }
``` ```
#### `set` #### `set`
Declaratively set `variableA` to next value `valueB`. Declaratively set `variableA` with `valueA` to `valueB`.
```js ```js
function Component() { function Component() {
this.state = { fruits: 0 }; this.state = { fruits: 0 };
@ -60,7 +67,7 @@ function Component() {
} }
``` ```
#### `reset` #### `reset`
Set something to its initial state/value. Set something back to its initial value.
```js ```js
const initialFruits = 5; const initialFruits = 5;
const fruits = initialFruits; const fruits = initialFruits;
@ -73,7 +80,7 @@ function resetFruits() {
resetFruits(); // fruits = 5 resetFruits(); // fruits = 5
``` ```
#### `compose` #### `compose`
Create new data from existing one. Create new data from the existing one. Probably, applicable mostly to strings.
```js ```js
function composePageUrl(pageName, pageId) { function composePageUrl(pageName, pageId) {
return `${pageName.toLowerCase()}-${pageId}`; return `${pageName.toLowerCase()}-${pageId}`;