Skip to content

Instantly share code, notes, and snippets.

View talamaska's full-sized avatar

Zlati Pehlivanov talamaska

View GitHub Profile
@talamaska
talamaska / Dart Class.dart
Created January 11, 2019 16:06 — forked from buntagonalprism/Dart Class.dart
Flutter and Dart collection of file templates for Android Studio development
#set( $nameparts = $NAME.split("_"))
#set( $namepart = '')
#set( $classname = '')
#foreach( $namepart in $nameparts )
#set( $classname = $classname + $namepart.substring(0, 1).toUpperCase() + $namepart.substring(1))
#end
class $classname {
// TODO: add class properties and methods
@talamaska
talamaska / custom.overlay.config.ts
Last active November 11, 2020 09:11
template modals
interface CustomOverlayConfig {
hasBackdropClick?: boolean;
isCentered?: boolean;
size?: any;
top?: string;
}
const DEFAULT_CUSTOM_CONFIG: CustomOverlayConfig = {
hasBackdropClick: false,
isCentered: true,
import { OverlayRef } from '@angular/cdk/overlay';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { Subject } from 'rxjs/Subject';
export class ConfirmationModalOverlayRef {
public events = new BehaviorSubject<any>(null);
constructor(private overlayRef: OverlayRef) { }
public close(): void {
this.overlayRef.dispose();
}
@talamaska
talamaska / form.modal.component.ts
Last active July 23, 2020 13:01
component portal modals
this.isSuccessSub = this.isSuccess$.subscribe((isSuccess) => {
if (isSuccess) {
this.dialogRef.close();
}
});
@talamaska
talamaska / loading-spinner.service.ts
Created May 15, 2018 13:53 — forked from caroso1222/loading-spinner.service.ts
Angular CDK - Portal and PortalHost
import {
Injectable,
ComponentFactoryResolver,
ApplicationRef,
Injector
} from '@angular/core';
import {
ComponentType,
Portal,
ComponentPortal,
@talamaska
talamaska / recipe.example.md
Created February 20, 2018 11:34 — forked from peterbsmyth/recipe.example.md
Making chained API Calls using @ngrx/Effects

Making chained API Calls using @ngrx/Effects

Purpose

This recipe is useful for cooking up chained API calls as a result of a single action.

Description

In the below example, a single action called POST_REPO is dispatched and it's intention is to create a new repostiory on GitHub then update the README with new data after it is created.
For this to happen there are 4 API calls necessary to the GitHub API:

  1. POST a new repostiry
  2. GET the master branch of the new repository
  3. GET the files on the master branch
@talamaska
talamaska / line.effect.ts
Created February 20, 2018 11:33 — forked from vteivans/line.effect.ts
Simple ngrx effect example with `withLatestFrom` operator for blog post: https://medium.com/@viestursv/how-to-get-store-state-in-ngrx-effect-fab9e9c8f087#.oekqp1ucb
import { Store, Action } from '@ngrx/store';
import { Actions, Effect } from '@ngrx/effects';
import { ADD_LINE } from './lines.reducer';
import { INC_PAGE_COUNT } from './pages.reducer';
import { AppState } from './app.store';
@Injectable()
export class LineEffects {
@talamaska
talamaska / conditional_effects.ts
Created February 20, 2018 11:32 — forked from vespertilian/conditional_effects.ts
Two options for conditional ngrx effects
@Effect()
selectAndLoadStore$: Observable<Action> = this.actions$
.ofType(storeActions.SELECT_AND_LOAD_STORE)
.withLatestFrom(this.store.select(ngrx.storeState))
.map(([action, storeState]) => [action.payload, storeState])
.switchMap(([storeName, storeState]) => {
const existsInStore = Boolean(storeState.urlNameMap[storeName]);
return Observable.if(
() => existsInStore,
Observable.of(new storeActions.SetSelectedStore(storeName)),
// Nothing changed here, works as previously.
@Effect() actionX$ = this.updates$
.ofType('ACTION_X')
.map(toPayload)
.switchMap(payload => this.api.callApiX(payload)
.map(data => ({type: 'ACTION_X_SUCCESS', payload: data}))
.catch(err => Observable.of({type: 'ACTION_X_FAIL', payload: err}))
);
{
"name": "admin",
"version": "1.0.0",
"scripts": {
"ng": "ng",
"yarn": "yarn",
"e2e:client": "ng e2e --app fw-app",
"lint:client": "ng lint --app fw-app",
"test:client": "ng test --app fw-app",
"build:client": "ng build --app fw-app",