@framejs/mixins
Version:
A set of mixing to help and speed up development of web components
39 lines (38 loc) • 1.13 kB
TypeScript
export interface IProps {
[key: string]: IProperty;
}
export interface IProperty {
type: Function;
reflectToAttribute?: boolean;
value?: string | boolean | object | number;
observer?: string;
notify?: boolean;
}
/**
* PropsMixins provides a slick way to write properties that
* reflects to attributes and observes on attribute changes and property changes
* with the same API.
*
* @mixin
* @example
* class MyClass extends PropsMixin {
* static get props() {
* return {
* myProp: {
* type: String, // String | Boolean | Object | Number | Array
* reflectToAttribute: true, // true | false (optional)
* value: 'Hello', // (optional)
* observer: '_myPropChanged' // (optional),
* notify: true (optional)
* }
* }
* }
*
* // Executes on load and every time the
* // attribute or property changes
* _myPropChanges(oldValue, newValue) {
* console.log(oldValue, newValue)
* }
* }
*/
export declare const PropsMixin: (Base?: any) => any;