trotyl / ng-vdom

(Developer Preview) A virtual-DOM extension for Angular, also work as React bridge.
260 stars 12 forks source link

Feature: pipe support in render function #30

Open trotyl opened 5 years ago

trotyl commented 5 years ago

Integrate Pipes with render function.

API Design

function pipe(type: Type<any>): (value: any, ...extras: any[]) => never

Example

import { AsyncPipe, DatePipe } from '@angular/common'
import { pipe, Renderable } from 'ng-renderable'

const async = pipe(AsyncPipe)
const date = pipe(DatePipe)

@Component()
class MyComponent extends Renderable {
  @Input() title: Observable<string>
  @Input() date: Date

  render() {
    return (
      <p title={ async(this.title) }>
        { date(this.date, 'fullDate') }
      </p>
    )
  }
}