Skip to content

Instantly share code, notes, and snippets.

atom.packages.onDidActivateInitialPackages (initialPackages) ->
atom.commands.add 'atom-text-editor', 'akonwi:rename-file', (e) ->
atom.commands.dispatch e.target, 'tree-view:rename'
if gitPlus = atom.packages.getActivePackage('git-plus')?.mainModule.provideService()
gitPlus.registerCommand 'atom-text-editor', 'akonwi:update-last-commit', ->
gitPlus.getRepo() # If there are multiple repos in the project, you will be prompted to select which to use
.then (repo) -> gitPlus.run repo, 'commit --all --amend --no-edit'
gitPlus.registerCommand 'atom-text-editor', 'akonwi:unstage-last-commit', ->
@akonwi
akonwi / echo.ts
Created April 22, 2019 15:58
minimal event emitter for single value type
interface Listener<T> {
(value: T): void;
}
class Echo<T> implements Disposable {
private listeners = new Set<Listener<T>>();
listen(listener: (value: T) => void) {
this.listeners.add(listener);
return new Disposable(() => {
function useDidChange(cb: (previous: any[]) => void, deps: any[]) {
const isMountedRef = React.useRef(false);
const cbRef = React.useRef(cb);
React.useEffect(() => {
cbRef.current = cb;
}, [cb]);
const previousRef = React.useRef(deps);
React.useEffect(() => {
if (isMountedRef.current) {