Skip to content

Instantly share code, notes, and snippets.

@onderceylan
onderceylan / ngsw-config.json
Last active January 27, 2024 11:19
Build a production ready PWA with Angular and Firebase - ngsw-config.json
{
"index": "/index.html",
"appData": {
"version": "1.1.0",
"changelog": "Added better resource caching"
},
"assetGroups": [
{
"name": "shell",
"installMode": "prefetch",
@ThomasBurleson
ThomasBurleson / untilDestroyed.ts
Last active April 18, 2023 07:47
Using untilViewDestroyed to link component ngOnDestroy to observable unsubscribe.
/**
* When manually subscribing to an observable in a view component, developers are traditionally required
* to unsubscribe during ngOnDestroy. This utility method auto-configures and manages that relationship
* by watching the DOM with a MutationObserver and internally using the takeUntil RxJS operator.
*
* Angular 7 has stricter enforcements and throws errors with monkey-patching of view component life-cycle methods.
* Here is an updated version that uses MutationObserver to accomplish the same goal.
*
* @code
*
@ThomasBurleson
ThomasBurleson / tickets.facade.md
Last active February 22, 2024 07:41
Using ngrx with Effects + Facades

NgRx State Management with TicketFacade

Facades are a programming pattern in which a simpler public interface is provided to mask a composition of internal, more-complex, component usages.

When writing a lot of NgRx code - as many enterprises do - developers quickly accumulate large collections of actions and selectors classes. These classes are used to dispatch and query [respectively] the NgRx Store.

Using a Facade - to wrap and blackbox NgRx - simplifies accessing and modifying your NgRx state by masking internal all interactions with the Store, actions, reducers, selectors, and effects.

For more introduction, see Better State Management with Ngrx Facades

@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active May 5, 2024 10:30
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

How to run nightly version of @ngrx/store along with new @ngrx/effects

Add new packages to your dependencies

Effects and store v2 are not on npm yet, so download them from my github.

"@ngrx/core": "1.0.0",
"@ngrx/store": "fxck/store#v2-test",
"@ngrx/effects": "fxck/effects",
@btroncone
btroncone / rxjs_operators_by_example.md
Last active July 16, 2023 14:57
RxJS 5 Operators By Example
@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

@newtriks
newtriks / app.js
Last active September 5, 2018 06:09
Playing with immutable state using RxJS
import {List, Record, toJS} from 'immutable';
import Rx, {Observable, Subject} from 'rx';
const initialState = Record({count: 0, text: '', items: List(), history: List(), future: List()});
const subject = new Subject();
const source = Observable.merge(subject)
.scan((currentState, action) => action(currentState), initialState());
source.subscribe(
state => {