https://github.com/ltd-beget/lanurite
Library for Models and Collection use in JS world. supported browser, Nodejs, TypeScript
https://github.com/ltd-beget/lanurite
angularjs backbone collection models react typescript vuejs
Last synced: 8 months ago
JSON representation
Library for Models and Collection use in JS world. supported browser, Nodejs, TypeScript
- Host: GitHub
- URL: https://github.com/ltd-beget/lanurite
- Owner: LTD-Beget
- License: mit
- Created: 2017-08-25T09:40:29.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-05-17T12:56:57.000Z (over 6 years ago)
- Last Synced: 2024-11-12T16:02:30.426Z (about 1 year ago)
- Topics: angularjs, backbone, collection, models, react, typescript, vuejs
- Language: TypeScript
- Homepage: https://pxyup.github.io/lanurite/
- Size: 664 KB
- Stars: 4
- Watchers: 22
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Lanurite
Library for Models and Collection use in JS worlds
Documentation:
https://pxyup.github.io/lanurite/
[](https://nodei.co/npm/lanurite/)
**For use in browser**
``
**For use in TypeScript**
```typescript
import * as Lanurite from "lanurite"
console.log(Lanurite.version)
```
**For use in NodeJS**
```javascript
var Lanurite = require("lanurite");
console.log(Lanurite.version)
```
## Example
```javascript
let model = new Lanurite.Model({name: "Robot"});
document.getElementById("test").innerHTML = model.get("name");
model.on("change", function (e) {
document.getElementById("test").innerHTML = model.get("name")
model.off("change", log)
});
let collection = new Lanurite.Collection();
collection.on("add", function (model) {
document.getElementById("collection").innerHTML += model.get("name") + "
"
})
collection.on("clear", function () {
document.getElementById("collection").innerHTML = "";
});
model.on("change", log);
collection.on("reset", function () {
getCollectionDOM();
});
getCollectionDOM();
function log(event){
console.log(event)
}
function getCollectionDOM() {
document.getElementById("collection").innerHTML = "";
collection.each((el) => {
document.getElementById("collection").innerHTML += el.get("name") + "
"
});
}
```