Skip to content

Instantly share code, notes, and snippets.

View fxck's full-sized avatar

Aleš fxck

View GitHub Profile
@fxck
fxck / action-enh-2.ts
Last active September 12, 2018 10:48
export class UserListRequest implements Action, LoadingAction {
readonly type = ActiontTypes.UserListRequest;
fxLoading = { add: ActiontTypes.UserListRequest };
}
export class UserListRequest implements Action {
readonly type = ActiontTypes.UserListRequest;
}
@Injectable()
export class UsersEffects {
@Effect()
private _onListRequest$ = this._actions$.pipe(
ofType('USER_LIST_REQUEST'),
map((action) => new LoadingAdd(action.type))
);
constructor(private _actions$: Actions) { }
}
export function reducer(
state = initialState,
action: Actions
) {
switch (action.type) {
case ActionTypes.Add:
return { data: [ ...state.data, action.payload ] };
case ActionTypes.Remove:
return { data: state.data.filter((id) => id !== action.payload) };
}
export enum ActionTypes {
Add = '[@my/loading] Add',
Remove = '[@my/loading] Remove'
}
export class Add {
readonly type = ActionTypes.Add;
constructor(public payload: string) { }
}
class State {
data: string[];
}
class Users {
list[]: string;
loading: boolean;
constructor() {
this.list = [];
this.loading = false;
}
}
@fxck
fxck / app.component.html
Last active March 13, 2017 13:02
angular dialog stacking
<div style="padding: 7px">
<foo-cmp>
<md-input-container>
<input mdInput placeholder="Whatever" type="text" [formControl]="form.get('whatever')">
</md-input-container>
<md-input-container>
<input mdInput placeholder="State" [mdAutocomplete]="auto" [formControl]="form.get('state')">
@fxck
fxck / app.component.html
Created March 13, 2017 12:53
angular dialog stacking
<div style="padding: 7px">
<button md-raised-button (click)="open = true">Open Dialog</button>
<dialog-cmp [open]="open">
<md-input-container>
<input mdInput placeholder="Whatever" [formControl]="form.get('whatever')">
</md-input-container>
<md-input-container>
@fxck
fxck / app.component.html
Last active March 6, 2017 13:28
material2 overlayclickthru
<div style="padding: 7px">
<sub-component
[options]="options$ | async"
[param]="routeParam$ | async">
</sub-component>
<sub-component
[options]="options$ | async"