Skip to content

Instantly share code, notes, and snippets.

Avatar

Thomas Burleson ThomasBurleson

View GitHub Profile
@ThomasBurleson
ThomasBurleson / refactor_4.md
Last active Dec 5, 2019
Refactor #4: RxJS Memory Leaks, Zombie Subscriptions, & Errors
View refactor_4.md

💚 Best Practices: Avoid 3 Common RxJS Issues

Bad-RxJS Issues

Developers often find scenarios where they are compelled to manaully subscribe to Observables in View components; these scenarios do not use the async pipe levels of manual subscription management. These manual subscriptions can lead to:

  • Observables + memory leaks, and
  • Zombie subscriptions
@ThomasBurleson
ThomasBurleson / untilDestroyed.ts
Last active Apr 14, 2021
Using untilViewDestroyed to link component ngOnDestroy to observable unsubscribe.
View untilDestroyed.ts
/**
* 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 Dec 25, 2021
Using ngrx with Effects + Facades
View tickets.facade.md

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

@piscisaureus
piscisaureus / pr.md
Created Aug 13, 2012
Checkout github pull requests locally
View pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: