knockout-decorators
Advanced tools
Comparing version 0.1.1 to 0.1.2
{ | ||
"name": "knockout-decorators", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Decorators for use Knockout JS in TypeScript and ESNext environments", | ||
@@ -5,0 +5,0 @@ "main": "dist/knockout-decorators.js", |
@@ -6,5 +6,6 @@ # Knockout Decorators | ||
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/gnaeus/knockout-decorators/master/LICENSE) | ||
[![npm version](https://img.shields.io/npm/v/knockout-decorators.svg?style=flat)](https://www.npmjs.com/package/knockout-decorators) | ||
### Example | ||
```ts | ||
```js | ||
import { observable, computed, component } from "knockout-decorators"; | ||
@@ -41,3 +42,3 @@ | ||
Property decorator that creates hidden `ko.observable` with ES6 getter and setter for it | ||
```ts | ||
```js | ||
class Model { | ||
@@ -54,3 +55,3 @@ @observable field = 123; | ||
Accessor decorator that wraps ES6 getter and setter (if defined) to hidden (maybe writeable) `ko.pureComputed` | ||
```ts | ||
```js | ||
class Person { | ||
@@ -72,3 +73,3 @@ @observable firstName = ""; | ||
#### <a name="knockout-decorators-component"></a> @component | ||
```ts | ||
```js | ||
@component(name: string, options?: Object); | ||
@@ -79,2 +80,3 @@ @component(name: string, template: any, options?: Object); | ||
Shorthand for registering Knockout component by decorating ViewModel class | ||
| argument | description | | ||
@@ -94,3 +96,3 @@ |----------|--------------------------------------------------------------------| | ||
then it will be registered as `viewModel:` in config object. | ||
```ts | ||
```js | ||
@component("my-component") | ||
@@ -109,5 +111,5 @@ class Component { | ||
If ViewModel constructor accepts two or three arguments, | ||
then it `createViewModel` factory is created and component config | ||
then `createViewModel:` factory is created and | ||
`{ element, templateNodes }` are passed as arguments to ViewModel constructor. | ||
```ts | ||
```js | ||
@component("my-component", | ||
@@ -114,0 +116,0 @@ require("./my-component.html"), |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18952
133