keet
Version:
Minimalist view layer for the web
92 lines (66 loc) • 2.76 kB
Markdown
---
id: api_createModel
title: CreateModel
sidebar_label: CreateModel
---
**Example**
```js
import { CreateModel } from 'keet'
class myModel extends CreateModel {
contructor() {
super()
// props
}
// new extended method
myMethod(...args){
this.list = args
}
}
const MyModel = new myModel()
```
* [keet/CreateModel](
* [.subscribe(fn)](
* [.add(obj)](
* [.update(updateObj)](
* [.filter(prop, value)](
* [.destroy(destroyObj)](
<a name="module_keet/CreateModel+subscribe"></a>
Subscribe to the model changes, the function callback first argument
is the ```model.list``` and the second argument is ```model.listFilter```
**Kind**: instance method of [<code>keet/CreateModel</code>](
| Param | Type | Description |
| --- | --- | --- |
| fn | <code>function</code> | the function callback for the subscribe |
<a name="module_keet/CreateModel+add"></a>
Add new object to the model list
**Kind**: instance method of [<code>keet/CreateModel</code>](
| Param | Type | Description |
| --- | --- | --- |
| obj | <code>Object</code> | new object to add into the model list |
<a name="module_keet/CreateModel+update"></a>
Update existing object in the model list
**Kind**: instance method of [<code>keet/CreateModel</code>](
| Param | Type | Description |
| --- | --- | --- |
| updateObj | <code>Object</code> | the updated properties |
<a name="module_keet/CreateModel+filter"></a>
Filter the model data by selected properties, constructor
instantiation should be apply with boolean true as argument
to enable filtering
**Kind**: instance method of [<code>keet/CreateModel</code>](
| Param | Type | Description |
| --- | --- | --- |
| prop | <code>string</code> | property of the object |
| value | <code>Object</code> <code>string</code> <code>number</code> <code>Boolean</code> | property value |
<a name="module_keet/CreateModel+destroy"></a>
Removed existing object in the model list
**Kind**: instance method of [<code>keet/CreateModel</code>](
| Param | Type | Description |
| --- | --- | --- |
| destroyObj | <code>Object</code> | the object ref to remove from the model |