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 tslib_1 from "tslib"; | |
import { Component, Input } from "@angular/core"; | |
import { Value, isBool, isNotNull } from "@trademe/ensure"; | |
var HelloComponent = (function () { | |
function HelloComponent() { } | |
tslib_1.__decorate([ | |
Value(isBool, isNotNull), | |
Input(), | |
tslib_1.__metadata("design:type", Boolean) |
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 { Component, Input } from '@angular/core'; | |
import { Value, isBool, isNotNull } from '@trademe/ensure'; | |
@Component({ | |
selector: 'hello' | |
// ... | |
}) | |
export class HelloComponent { | |
@Value(isBool, isNotNull) @Input() | |
public primary: boolean; |
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 { Component, Input } from '@angular/core'; | |
import { isBool } from './is-bool'; | |
@Component({ | |
// ... | |
}) | |
export class HelloComponent { | |
@isBool() @Input() | |
public primary: boolean; | |
} |
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 VALUE_KEY = '__value_'; | |
export function isBool (): PropertyDecorator { | |
return (target: any, propertyKey: string) => { | |
Object.defineProperty(target, propertyKey, { | |
get: function () { | |
return this[`${VALUE_KEY}${propertyKey}`]; | |
}, | |
set: function (value) { | |
this[`${VALUE_KEY}${propertyKey}`] = value != null && `${value}` !== 'false'; |
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 { Component, Input } from '@angular/core'; | |
@Component({ | |
// ... | |
}) | |
export class HelloComponent { | |
private _primary: boolean; | |
@Input() get primary (): boolean { | |
return this._primary; | |
} |
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
function PropertyDecorator (propertyOptions) { | |
// Modify the property in some way: | |
return propertyDescriptor; | |
} | |
function MethodDecorator (methodOptions) { | |
// Modify the method in some way: | |
return methodDescriptor; | |
} |
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
@ClassDecorator() | |
class MyClass { | |
@PropertyDecorator() | |
public myProperty: boolean = true; | |
@MethodDecorator() | |
public myMethod(): boolean { | |
return this.myProperty; | |
}; | |
} |
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
function PropertyDecorator (property) { | |
// Modify the property in some way: | |
return property; | |
} | |
function MethodDecorator (method) { | |
// Modify the method in some way: | |
return method; | |
} |
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
function Decorator (constructor) { | |
constructor.bang = 'boop!'; | |
return constructor; | |
} | |
const MyClass = Decorator(class _MyClass { }); | |
console.log(MyClass.bang); |
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
<my-card> | |
<my-card-video | |
myCardHero | |
video="https://www.youtube.com/embed/cbP2N1BQdYc?controls=0"> | |
</my-card-video> | |
<my-card-title>Cute cat videos!</my-card-title> | |
<my-card-details | |
myCardContents | |
price="1000000" | |
listed="09/06/2012"> |