This file contains hidden or 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
var TodosComponent = /** @class */ (function () { | |
function TodosComponent(store) { | |
this.store = store; | |
this.todos = this.store.pipe(select('todos')); | |
} | |
TodosComponent.ngComponentDef = defineComponent({ | |
type: TodosComponent, | |
selectors: [["todos-cmp"]], | |
factory: function TodosComponent_Factory(t) { |
This file contains hidden or 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
function fromStore(config: {[k: string]: string}) { | |
return (def: ComponentDef<any>) => { | |
const originalFactory = def.factory; // original factory creating a component | |
def.factory = () => { | |
const cmp = originalFactory(def.type); // component instance | |
const store = directiveInject(TodoStore); // using DI to get the store | |
config.forEach((key: string) => { | |
cmp[key] = store.pipe(select(config[key])); | |
}); | |
return cmp; // return the patched component |
This file contains hidden or 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({ | |
selector: 'todos-cmp', | |
template: ` | |
<div *ngFor="let t of todos|async"> | |
{{t.description}} | |
</div> | |
` | |
}) | |
@FromStore({todos: 'todos’}) | |
class TodosComponent { |
This file contains hidden or 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
function FromStore(config: {[k: string]: string}) { | |
return (clazz: any) => { | |
const originalFactory = clazz.ngComponentDef.factory; | |
clazz.ngComponentDef.factory = () => { | |
const cmp = originalFactory(clazz.ngComponentDef.type); | |
const store = directiveInject(Store); | |
Object.keys(config).forEach((key: string) => { | |
cmp[key] = store.pipe(select(config[key])); | |
}); | |
return cmp; |
This file contains hidden or 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
factory: function TodosComponent_Factory(t) { | |
return new (t || TodosComponent)(directiveInject(Store)); | |
}, |
This file contains hidden or 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
var TodosComponent = /** @class */ (function () { | |
function TodosComponent(store) { | |
this.store = store; | |
this.todos = this.store.pipe(select('todos')); | |
} | |
TodosComponent.ngComponentDef = defineComponent({ | |
type: TodosComponent, | |
selectors: [["todos-cmp"]], | |
factory: function TodosComponent_Factory(t) { |
This file contains hidden or 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({ | |
selector: 'todos-cmp', | |
template: ` | |
<div *ngFor="let t of todos|async"> | |
{{t.description}} | |
</div> | |
` | |
}) | |
class TodosComponent { | |
todos: Observable<Todo[]> = this.store.pipe(select('todos')); |
This file contains hidden or 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: ` | |
<div #dynamic></div> | |
` | |
}) | |
class DynamicContentCompoent { | |
@ViewChild('#dynamic') el: ElementRef; | |
constructor(private loader: CmsTemplateLoader) {} | |
This file contains hidden or 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 { BrowserModule } from '@angular/platform-browser'; | |
import { NgModule, Injector } from '@angular/core'; | |
import { createCustomElement } from '@angular/elements'; | |
import { HelloComponent } from './hello.component'; | |
@NgModule({ | |
declarations: [AppComponent], | |
imports: [BrowserModule], | |
providers: [], |
This file contains hidden or 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 express from 'express'; | |
import {Ticket} from "@myorg/data"; | |
const app = express(); | |
const tickets: Ticket[] = [ | |
{ | |
id: 1, | |
title: 'Login page is broken' | |
}, |