This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as rx from 'rxjs'; | |
const delays = [3000, 2000, 500]; | |
const switchMapOnNext = (project) => (source) => { | |
return new rx.Observable((observer) => { | |
let previousSubs = new rx.Subscription(); | |
const subscription = source.subscribe((value) => { | |
const result$ = project(value); | |
const currentPreviousSubs = previousSubs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>👨🏻🍳🅰️ Ngx Light by Younes @ Marmicode.io</title> | |
<meta name="description" content="👨🏻🍳🅰️ Ngx Light" /> | |
<meta name="viewport" content="width=device-width,initial-scale=1" /> | |
<script type="importmap"> | |
{ | |
"imports": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>👨🏻🍳🅰️ Ngx Light by Younes @ Marmicode.io</title> | |
<meta name="description" content="👨🏻🍳🅰️ Ngx Light" /> | |
<meta name="viewport" content="width=device-width,initial-scale=1" /> | |
<script type="importmap"> | |
{ | |
"imports": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { switchMap } from 'rxjs/operators'; | |
action$; | |
state$; // facade.country$ etc... | |
repository$; | |
fetch$.pipe(withLatestFrom(facade.country$)); | |
waitLatestFrom = (action$) => | |
action$.pipe( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @hack detect when story is changed and reload because custom elements | |
* break HMR. | |
* Storybook will replace storybook-dynamic-app-root's children. | |
* Then we reload the page to redefine elements. | |
*/ | |
const rootEl = document.querySelector('#root'); | |
rootEl.addEventListener('DOMNodeRemoved', (evt) => { | |
if (evt.relatedNode === rootEl) { | |
document.location.reload(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const u1 = {firstName: 'Foo'} | |
const u2 = {firstName: 'John'} | |
const body = JSON.parse('{"__proto__": {"admin": true}}') | |
function vulnerableExtend(dst, src) { | |
Object.entries(src) | |
.forEach(([k, v]) => { | |
if (k in dst) { | |
vulnerableExtend(dst[k], src[k]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@NgModule({ | |
imports: [ | |
RoutingModule.forChild([ | |
{ | |
path: 'catalog', | |
# Or, you can lazy load catalog if you wish. | |
component: SandwichCatalogViewComponent | |
} | |
]), | |
SandwichCatalogViewModule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@NgModule({ | |
imports: [ | |
RoutingModule.forRoot([ | |
{ | |
path: 'sandwich', | |
loadChildren: './sandwich/sandwich-views.module#SandwichViewsModule' | |
} | |
]) | |
] | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
template: `` | |
}) | |
export class AppComponent extends Renderable { | |
render() { | |
return ( | |
<h1>Hello World!</h1> | |
) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @todo when `deps` will be added to `Component` definition, | |
* we could return `{deps, template}` then use it like this: | |
* ``` | |
* @Component({ | |
* selector: 'wt-root', | |
* ...ngTemplate`<${Child}></${Child}>` | |
* }) | |
* ``` |
NewerOlder