Skip to content

Instantly share code, notes, and snippets.

View adrianfaciu's full-sized avatar
🎯
Focusing

Adrian Fâciu adrianfaciu

🎯
Focusing
View GitHub Profile
<ng-template appNgLoop #nr [appNgLoopOf]="numbers">
<div>
{{ nr }} - Foo
</div>
</ng-template>
<div *appNgLoop="let nr of numbers; index as i">
{{ nr }} - Foo
Index: {{ i }}
</div>
ngOnChanges() {
this.container.clear();
for (const input of this.appNgLoopOf) {
this.container.createEmbeddedView(this.template, {
$implicit: input,
index: this.appNgLoopOf.indexOf(input),
});
}
}
ngOnChanges() {
for (const input of this.appNgLoop) {
this.container.createEmbeddedView(this.template);
}
}
export class NgLoopDirective implements OnInit {
constructor(private container: ViewContainerRef,
private template: TemplateRef<any>,
) { }
ngOnInit(): void {
this.container.createEmbeddedView(this.template);
}
}
import { Directive } from '@angular/core';
@Directive({
selector: '[appNgLoop]'
})
export class NgLoopDirective {
constructor() { }
}
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// Choose either "stable" for receiving highly polished,
// or "canary" for less polished but more frequent updates
updateChannel: 'stable',
this.locationService.go('item/12');
it('can fetch data with debounce (test scheduler)', () => {
const source = cold('a', { a: { type: actions.DATA_WITH_DEBOUNCE_FETCH } });
mockObservableWithScheduler(getTestScheduler());
const effect = new AppTimeEffect(new Actions(source));
// - is a 10 frame interval, since we use 100 in the effect we use 10 - characters
const expected = cold('----------a', { a: { type: actions.DATA_WITH_DEBOUNCE_FETCH_SUCCESS } });
expect(effect.fetchDataWithDebounce$).toBeObservable(expected);
});
it('can fetch data with debounce (mocking debounce)', () => {
const source = cold('a', { a: { type: actions.DATA_WITH_DEBOUNCE_FETCH } });
mockObservable();
const effect = new AppTimeEffect(new Actions(source));
const expected = cold('a', { a: { type: actions.DATA_WITH_DEBOUNCE_FETCH_SUCCESS } });
expect(effect.fetchDataWithDebounce$).toBeObservable(expected);
});