This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Injectable() | |
| export class ViewArticlePageStateService { | |
| private currentState: ViewArticlePageState = initialState | |
| private id: StateAtom<number> = new StateAtom(initialState.id) | |
| private article: StateAtom<Article> = new StateAtom(initialState.article) | |
| private loading: StateAtom<boolean> = new StateAtom(initialState.loading) | |
| private searchTerm: StateAtom<string> = new StateAtom(initialState.searchTerm) | |
| private comments: StateAtom<Comment[]> = new StateAtom(initialState.comments) | |
| private commentsPagination: StateAtom<Params> = new StateAtom(initialState.commentsPagination) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { BehaviorSubject, Observable } from 'rxjs' | |
| import { distinctUntilChanged } from 'rxjs/operators' | |
| export class StateAtom<T> { | |
| value$: Observable<T> | |
| private store: BehaviorSubject<T> | |
| private value: T | |
| private initialValue: T |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| ############################################### | |
| # To use: | |
| # wget https://raw.github.com/gist/4411254 | |
| # chmod 777 github-ubuntu.sh | |
| # ./github-ubuntu.sh | |
| ############################################### | |
| echo "*****************************************" | |
| echo " Step 1: Check your keys" | |
| echo "*****************************************" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Run file | |
| * | |
| * `tsc flatten.ts && node flatten.js` | |
| * | |
| * Given following object: | |
| { | |
| test: "test1", | |
| same: "same", | |
| nested: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class ObjectDiff { | |
| isObject(obj: Object): boolean { | |
| return typeof obj === 'object' && !Array.isArray(obj) | |
| } | |
| isArray(obj: Object): boolean { | |
| return Array.isArray(obj) | |
| } |
NewerOlder