├── .gitignore ├── package.json ├── LICENSE ├── snippets ├── coffee.cson ├── live.cson └── babel.cson └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "redux-snippets", 3 | "version": "0.2.2", 4 | "description": "Atom Snippets for Redux", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/jhen0409/atom-redux-snippets.git" 8 | }, 9 | "keywords": [ 10 | "react", 11 | "redux", 12 | "snippets", 13 | "es6", 14 | "babel", 15 | "coffeescript", 16 | "livescript" 17 | ], 18 | "engines": { 19 | "atom": ">0.174.0" 20 | }, 21 | "author": "Jhen ", 22 | "license": "MIT", 23 | "bugs": { 24 | "url": "https://github.com/jhen0409/atom-redux-snippets.git/issues" 25 | }, 26 | "homepage": "https://github.com/jhen0409/atom-redux-snippets.git" 27 | } 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Jhen-Jie Hong 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /snippets/coffee.cson: -------------------------------------------------------------------------------- 1 | '.source.coffee': 2 | 3 | 'import redux': 4 | prefix: 'rdx-ipt' 5 | body: ''' 6 | { ${1:applyMiddleware, createStore, combineReducers, compose, bindActionCreators} } = require 'redux' 7 | ''' 8 | 9 | 'import redux/react': 10 | prefix: 'rdx-iptc' 11 | body: ''' 12 | { ${1:Provider, connect} } = require 'react-redux' 13 | ''' 14 | 15 | 'action': 16 | prefix: 'rdx-act' 17 | body: ''' 18 | exports.${1:addTodo} = ($2) -> 19 | $3 20 | ''' 21 | 22 | 'async-action': 23 | prefix: 'rdx-acta' 24 | body: ''' 25 | exports.${1:addTodo} = ($2) -> 26 | (dispatch, getState) -> 27 | $4 28 | 29 | dispatch $3 30 | ''' 31 | 32 | 'action-type': 33 | prefix: 'rdx-tp' 34 | body: ''' 35 | exports.$1 = '$1'$2 36 | ''' 37 | 38 | 'actions-map': 39 | prefix: 'rdx-map' 40 | body: ''' 41 | actionsMap = 42 | \"#{$1}\": (state, action) -> 43 | $2 44 | ''' 45 | 46 | 'map-action': 47 | prefix: 'rdx-mapact' 48 | body: ''' 49 | \"#{$1}\": (state, action) -> 50 | $2 51 | ''' 52 | 53 | 'reducer': 54 | prefix: 'rdxer' 55 | body: ''' 56 | module.exports = (state = initialState, action) -> 57 | $2 58 | 59 | state 60 | ''' 61 | 62 | 'middleware': 63 | prefix: 'rdx-mdw' 64 | body: ''' 65 | module.exports = ({ dispatch, getState }) -> 66 | next -> action -> 67 | ${2:next action} 68 | ''' -------------------------------------------------------------------------------- /snippets/live.cson: -------------------------------------------------------------------------------- 1 | '.source.livescript': 2 | 3 | 'import redux': 4 | prefix: 'rdx-ipt' 5 | body: ''' 6 | require! redux: { ${1:apply-middleware, create-store, combine-reducers, compose, bind-action-creators} } 7 | ''' 8 | 9 | 'import redux/react': 10 | prefix: 'rdx-iptc' 11 | body: ''' 12 | require! 'react-redux': { ${1:Provider, connect} } 13 | ''' 14 | 15 | 'action': 16 | prefix: 'rdx-act' 17 | body: ''' 18 | export ${1:add-todo}: ($2) -> 19 | $3 20 | ''' 21 | 22 | 'async-action': 23 | prefix: 'rdx-acta' 24 | body: ''' 25 | export ${1:add-todo}: ($2) -> 26 | (dispatch, get-state) -> 27 | $4 28 | 29 | dispatch $3 30 | ''' 31 | 32 | 'action-type': 33 | prefix: 'rdx-tp' 34 | body: ''' 35 | export const $1 = '$1'$2 36 | ''' 37 | 38 | 'actions-map': 39 | prefix: 'rdx-map' 40 | body: ''' 41 | const actions-map = 42 | "#{$1}": (state, action) -> 43 | $2 44 | ''' 45 | 46 | 'map-action': 47 | prefix: 'rdx-mapact' 48 | body: ''' 49 | \"#{$1}\": (state, action) -> 50 | $2 51 | ''' 52 | 53 | 'reducer': 54 | prefix: 'rdxer' 55 | body: ''' 56 | module.exports = (state = initial-state, action) -> 57 | $1 58 | 59 | state 60 | ''' 61 | 62 | 'middleware': 63 | prefix: 'rdx-mdw' 64 | body: ''' 65 | module.exports = ({ dispatch, getState }) -> 66 | next -> action -> 67 | ${1:next action} 68 | ''' -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Atom Redux Snippets 2 | 3 | Atom snippets for [Redux](https://github.com/gaearon/redux). This snippets uses Babel(ES2015, ES2016), CoffeeScript, LiveScript syntax. 4 | 5 | ## Support Language 6 | 7 | - Babel (ES2015, ES2016) 8 | - CoffeeScript 9 | - LiveScript 10 | 11 | ## Usage 12 | 13 | - import redux (rdx-ipt) 14 | ```js 15 | import { ${1:applyMiddleware, createStore, combineReducers, compose, bindActionCreators} } from 'redux'; 16 | ``` 17 | - import react-redux (rdx-iptc) 18 | ```js 19 | import { ${1:Provider, connect} } from 'react-redux'; 20 | ``` 21 | 22 | - action (rdx-act) 23 | ```js 24 | export function ${1:addTodo}($2) { 25 | $4 26 | 27 | return { 28 | $3 29 | }; 30 | } 31 | ``` 32 | - async-action (rdx-acta) 33 | ```js 34 | export function ${1:addTodo}($2) { 35 | return (dispatch, getState) => { 36 | $4 37 | 38 | dispatch({ 39 | $3 40 | }); 41 | }; 42 | } 43 | ``` 44 | - action-type (rdx-tp) 45 | ```js 46 | export const $1 = '$1';$2 47 | ``` 48 | - actions-map (rdx-map) 49 | ```js 50 | const actionsMap = { 51 | [$1]: (state, action) => { 52 | $2 53 | } 54 | }; 55 | ``` 56 | - map-action (rdx-mapact) 57 | ```js 58 | [$1]: (state, action) => { 59 | $2 60 | } 61 | ``` 62 | - reducer (rdxer) 63 | ```js 64 | export default function ${1:todos}(state = initialState, action) { 65 | $2 66 | 67 | return state; 68 | } 69 | ``` 70 | - middleware (rdx-mdw) 71 | ```js 72 | export default function $1({ dispatch, getState }) { 73 | return next => action => { 74 | 75 | ${2: next(action);} 76 | }; 77 | } 78 | ``` 79 | 80 | about LiveScript, CoffeeScript snippets generated code, see [live.cson](snippets/live.cson) and [coffee.cson](snippets/coffee.cson). 81 | 82 | ## LICENSE 83 | 84 | [MIT](LICENSE) -------------------------------------------------------------------------------- /snippets/babel.cson: -------------------------------------------------------------------------------- 1 | '.source.js.jsx': 2 | 3 | 'import redux': 4 | prefix: 'rdx-ipt' 5 | body: ''' 6 | import { ${1:applyMiddleware, createStore, combineReducers, compose, bindActionCreators} } from 'redux'; 7 | ''' 8 | 9 | 'import redux/react': 10 | prefix: 'rdx-iptc' 11 | body: ''' 12 | import { ${1:Provider, connect} } from 'react-redux'; 13 | ''' 14 | 15 | 'action': 16 | prefix: 'rdx-act' 17 | body: ''' 18 | export function ${1:addTodo}($2) { 19 | $4 20 | 21 | return { 22 | $3 23 | }; 24 | } 25 | ''' 26 | 27 | 'async-action': 28 | prefix: 'rdx-acta' 29 | body: ''' 30 | export function ${1:addTodo}($2) { 31 | return (dispatch, getState) => { 32 | $4 33 | 34 | dispatch({ 35 | $3 36 | }); 37 | }; 38 | } 39 | ''' 40 | 41 | 'action-type': 42 | prefix: 'rdx-tp' 43 | body: ''' 44 | export const $1 = '$1';$2 45 | ''' 46 | 47 | 'actions-map': 48 | prefix: 'rdx-map' 49 | body: ''' 50 | const actionsMap = { 51 | [$1]: (state, action) => { 52 | $2 53 | } 54 | }; 55 | ''' 56 | 57 | 'map-action': 58 | prefix: 'rdx-mapact' 59 | body: ''' 60 | [$1]: (state, action) => { 61 | $2 62 | } 63 | ''' 64 | 65 | 'reducer': 66 | prefix: 'rdxer' 67 | body: ''' 68 | export default function ${1:todos}(state = initialState, action) { 69 | $2 70 | 71 | return state; 72 | } 73 | ''' 74 | 75 | 'middleware': 76 | prefix: 'rdx-mdw' 77 | body: ''' 78 | export default function $1({ dispatch, getState }) { 79 | return next => action => { 80 | 81 | ${2:next(action);} 82 | }; 83 | } 84 | ''' --------------------------------------------------------------------------------