Skip to content

Instantly share code, notes, and snippets.

@rakannimer
Last active November 25, 2016 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rakannimer/32bdda5ca23ee9d8964a75be9e003431 to your computer and use it in GitHub Desktop.
Save rakannimer/32bdda5ca23ee9d8964a75be9e003431 to your computer and use it in GitHub Desktop.
Some atom snippets
# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
#
# You can create a new snippet in this file by typing "snip" and then hitting
# tab.
#
# An example CoffeeScript snippet to expand log to console.log:
#
# '.source.coffee':
# 'Console log':
# 'prefix': 'log'
# 'body': 'console.log $1'
#
# Each scope (e.g. '.source.coffee' above) can only be declared once.
#
# This file uses CoffeeScript Object Notation (CSON).
# If you are unfamiliar with CSON, you can read more about it in the
# Atom Flight Manual:
# https://atom.io/docs/latest/using-atom-basic-customization#cson
'.js':
'ES6 React Component':
'prefix':'react-component'
'body': """
import React from 'react'
class $1 extends React.Component {
constructor(props){
super(props);
}
render() {
return (
$2
);
}
};
export default $1;
"""
'JSON stringify':
'prefix': 'str'
'body': 'JSON.stringify($1, 2, 2)'
'Console log':
'prefix': 'log'
'body': 'console.log($1)'
'JSON.stringify()':
'prefix': 'json'
'body': 'JSON.stringify($1, 2, 2)'
'logProps':
'prefix': 'logProps'
'body': """
console.warn(`Props! ${JSON.stringify(this.props, 2, 2)}`);
"""
'Console warn object':
'prefix': 'warnObj'
'body': """
console.warn(JSON.stringify($1, 2, 2));
"""
'Console warn':
'prefix': 'warn'
'body': 'console.warn($1)'
'et3TryCatch':
'prefix': 'et3TryCatch'
'body': """
try {
} catch (err) {
throw new $2Error(err, '', {});
}
"""
'Sagas Dependencies':
'prefix': 'sagaDep'
'body': """
import { takeEvery, takeLatest } from 'redux-saga'
import { call, put } from 'redux-saga/effects'
import {store} from './store';
"""
'Saga Template':
'prefix': 'saga'
'body': """
import { takeEvery, takeLatest } from 'redux-saga'
import { call, put } from 'redux-saga/effects'
import {store} from '$1/store';
import { $4 } from $5
function* $2(action) {
try {
let currentState = store.getState();
let input = action.$6;
yield put({type: "$3_STARTED", user: {}});
yield call( $4 , note );
yield put({type: "$3_SUCCESS", note: note} );
} catch (e) {
yield put({type: "$3_FAILED", message: e.message});
}
}
/*
Starts fetchUser on each dispatched `USER_FETCH_REQUESTED` action.
Allows concurrent fetches of user.
*/
function* $2Saga() {
yield* takeEvery("$3", $2);
}
export default $2Saga;
"""
'Add Saga':
'prefix': 'sagaAdd'
'body': """
import $1 from './$1'
sagas['$1'] = $1
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment