Skip to content

Instantly share code, notes, and snippets.

View CharGrnmn's full-sized avatar

Charlie Greenman CharGrnmn

View GitHub Profile
@CharGrnmn
CharGrnmn / two-subscribes.ts
Created November 11, 2019 10:39
Rxjs, cold, with two subscribes
import { Subject } from 'rxjs';
const randomVals$ = new Subject().next(Math.random());}
// Subscribe to run the combined functions
randomVals$.subscribe(x => console.log(x));
// 0.24957144215097515 (random number)
randomVals$.subscribe(x => console.log(x));
// 0.004617340049055896 (random number)
@CharGrnmn
CharGrnmn / two-subscribes.ts
Created November 11, 2019 10:39
Rxjs, cold, with two subscribes
import { Subject } from 'rxjs';
const randomVals$ = new Subject().next(Math.random());}
// Subscribe to run the combined functions
randomVals$.subscribe(x => console.log(x));
// 0.24957144215097515 (random number)
randomVals$.subscribe(x => console.log(x));
// 0.004617340049055896 (random number)
@CharGrnmn
CharGrnmn / pokemon.effects.ts
Created November 10, 2019 14:57
Pokemon map example
@Effect()
loadAllBlogPosts$: Observable<any> = this.actions$.pipe(
ofType(PokemonActions.loadPokemon),
mergeMap(() =>
this.postsService.getAll().pipe(
map(posts => PokemonActions.loadPokemonSuccess({ posts })),
catchError(message => of(PokemonActions.loadPostsFailed({ message })))
)
)
);
@CharGrnmn
CharGrnmn / search-bar.effects.ts
Created November 10, 2019 14:47
switchMap Example
@Effect()
findAddresses: Observable<any> = this.actions.pipe(
ofType(LocationActionTypes.FindAddresses),
map(action => action.partialAddress),
debounceTime(400),
distinctUntilChanged(),
switchMap(partialAddress => this.backend
.findAddresses(partialAddress)
.pipe(
map(results => new FindAddressesFulfilled(results)),
@CharGrnmn
CharGrnmn / pokemon.effects.ts
Created November 10, 2019 14:42
mergeMap effects example
@Effect()
loadAllBlogPosts$: Observable<any> = this.actions$.pipe(
ofType(PokemonActions.loadPokemon),
mergeMap(() =>
this.postsService.getAll().pipe(
map(posts => PokemonActions.loadPokemonSuccess({ posts })),
catchError(message => of(PokemonActions.loadPostsFailed({ message })))
)
)
);
import { LOCALE_ID, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from '../src/app/app.component';
@NgModule({
imports: [ BrowserModule ],
declarations: [ AppComponent ],
providers: [ { provide: LOCALE_ID, useValue: 'fr' } ],
bootstrap: [ AppComponent ]
import { LOCALE_ID, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from '../src/app/app.component';
@NgModule({
imports: [ BrowserModule ],
declarations: [ AppComponent ],
providers: [ { provide: LOCALE_ID, useValue: 'fr' } ],
bootstrap: [ AppComponent ]
import { enableProdMode, TRANSLATIONS, TRANSLATIONS_FORMAT } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
import { enableProdMode, TRANSLATIONS, TRANSLATIONS_FORMAT } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
...
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": { ... },
"configurations": {
"fr": {
"aot": true,
"outputPath": "dist/my-project-fr/",
"i18nFile": "src/locale/messages.fr.xlf",