diff --git a/awesome-redux.md b/awesome-redux.md index 871a27da1..b5d7274d5 100644 --- a/awesome-redux.md +++ b/awesome-redux.md @@ -23,6 +23,19 @@ A standard for flux action objects. An action may have an `error`, `payload` and { type: 'ADD_TODO', payload: new Error(), error: true } ``` +### [redux-multi](https://github.com/ashaffer/redux-multi) +Dispatch multiple actions in one action creator. + +```js +store.dispatch([ + { type: 'INCREMENT', payload: 2 }, + { type: 'INCREMENT', payload: 3 } +]) +``` + +Async +----- + ### [redux-promise](https://github.com/acdlite/redux-promise) Pass promises to actions. Dispatches a flux-standard-action. @@ -61,12 +74,28 @@ Pass side effects declaratively to keep your actions pure. } ``` -### [redux-multi](https://github.com/ashaffer/redux-multi) -Dispatch multiple actions in one action creator. +### [redux-thunk](https://www.npmjs.com/package/redux-thunk) +Pass "thunks" to as actions. ```js -store.dispatch([ - { type: 'INCREMENT', payload: 2 }, - { type: 'INCREMENT', payload: 3 } -]) +function fetchPosts () { + // Usually returns a promise. + return function (dispatch, getState) { + dispatch({ type: 'posts:fetch' }) + return API.get('/posts') + .then(payload => dispatch({ type: 'posts:fetch:done', payload }) + .then(error => dispatch({ type: 'posts:fetch:error', error }) + } +} + +store.dispatch(fetchPosts()) + +// That's actually shorthand for: +fetchPosts()(store.dispatch, store.getState) + +// Optional: since fetchPosts returns a promise, it can be chained +// for server-side rendering +store.dispatch(fetchPosts()).then(() => { + ReactDOMServer.renderToString() +}) ``` diff --git a/meta-tags.md b/meta-tags.md new file mode 100644 index 000000000..70c876f7c --- /dev/null +++ b/meta-tags.md @@ -0,0 +1,49 @@ +--- +title: Meta-tags +category: Ruby libraries +--- + +### Titles + +```rb +set_meta_tags title: 'Member Login' +# Some Page Title +set_meta_tags site: 'Site Title', title: 'Member Login' +# Site Title | Page Title +set_meta_tags site: 'Site Title', title: 'Member Login', reverse: true +# Page Title | Site Title +``` + +### Others + +```rb +set_meta_tags description: "All text about keywords, other keywords" +set_meta_tags keywords: %w[abc def ghi] +set_meta_tags noindex: true +set_meta_tags nofollow: true +set_meta_tags canonical: 'http://...' +set_meta_tags icon: 'favicon.ico' +set_meta_tags author: 'http://...' +set_meta_tags alternate: { 'fr' => 'http://...' } +set_meta_tags prev: 'http://...' +set_meta_tags next: 'http://...' +set_meta_tags og: { image: ['...'] } +``` + +### In views + +```rb +<%= display_meta_tags %> +``` + +```rb +<% title 'Member Login' %> +<% description 'My page' %> +<% keywords '..' %> + +

<%= title %>

+``` + +### Reference + +Accurate as of 2.1.0. See .