Skip to content

Instantly share code, notes, and snippets.

View btroncone's full-sized avatar

Brian Troncone btroncone

View GitHub Profile
@btroncone
btroncone / ngrxintro.md
Last active February 9, 2024 15:37
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series

Comprehensive Introduction to @ngrx/store

By: @BTroncone

Also check out my lesson @ngrx/store in 10 minutes on egghead.io!

Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!

Table of Contents

@btroncone
btroncone / rxjs_operators_by_example.md
Last active July 16, 2023 14:57
RxJS 5 Operators By Example
@btroncone
btroncone / subscription-cleanup.md
Last active April 19, 2022 22:29
Cleaning up subscriptions in Angular

Which do you prefer?

Adding to common sub, calling subscription.unsubscribe() in ngOnDestroy:

export class MyComponent {
  private _subscription: Subscription;
  
  ngOnInit() {
    this._subscription = myObservable
@btroncone
btroncone / authentication.ts
Last active April 10, 2022 06:44
Angular 2 application role access decorator, wrapping built in CanAccess functionality. Prevents view transitions when user roles are not appropriate.
import { Injectable } from 'angular2/core';
import { Storage } from './storage';
import { CurrentUser } from '../interfaces/common';
@Injectable()
export class Authentication{
private _storageService : Storage;
private _userKey : string = "CURRENT_USER";
constructor(storageService : Storage){
@btroncone
btroncone / README.md
Created March 30, 2016 02:53
angular 2 basic counter

angular 2 basic counter

Basic counter in Angular 2.

@btroncone
btroncone / bootstrap.ts
Last active May 10, 2021 20:53
Basic demonstration of how NgRx middleware can be used to keep local storage in sync with user-defined state slices.
//specify what state slices you would like to keep synced with local storage
export function main() {
return bootstrap(TodoApp, [
provideStore(APP_REDUCERS),
localStorageMiddleware('todos', 'visibilityFilter')
])
.catch(err => console.error(err));
}
@btroncone
btroncone / README.md
Created March 30, 2016 02:44
@ngrx/store counter

@ngrx/store counter

Basic counter w/ @ngrx/store.

@btroncone
btroncone / service.spec.ts
Last active September 4, 2019 08:16
Angular service testing (constructor)
import { inject, TestBed } from '@angular/core/testing';
import { of } from 'rxjs/observable/of';
import { LoggingService, LocalStorageService } from '../';
import { RouterEventService } from '../../routing';
export class MockLocalStorageService {
setItem() {}
getItem() { return []; }
}
export class MockRouterEventService {
@btroncone
btroncone / todo-item.ts
Last active February 20, 2019 19:48
Ng2 Observable Todo-Service
import {Component, Input, Output, EventEmitter} from "angular2/core";
import {Todo} from "../services/Todo-Service";
@Component({
selector: 'todo-item',
styles: [
`
.complete{
text-decoration: line-through;
}