1.1.0 • Published 5 years ago

@iljucha/application v1.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
5 years ago

Application

Usage

Create an application

./apps/example.js

Create your application.

import { Application, define } from "../node_modules/@iljucha/application/src/index.js"

export class AppExample extends Application {
    // Use super() if you need the constructor
    constructor(favouriteAnimal) {
        super()
        this.favouriteAnimal = favouriteAnimal
    }

    get selector() {
        return "app-example"
    }
    
    get styles() {
        return /*css*/`
            p {
                color: pink;
            }
        `
    }

    get template() {
        return /*html*/`
            My favourite animal is ${this.favouriteAnimal}.
            <p>The End</p>
        `
    }
    
    get paragraph() {
        return this.select("p")
    }
    
    set favouriteAnimal(value) {
        this._favouriteAnimal = value
    }
    
    get favouriteAnimal() {
        return this._favouriteAnimal
    }
    
    onConnect() {
        console.log("app-exampe spawned")
    }
    
    onDisconnect() {
        console.log("app-example removed from the DOM")
    }
    
    // Example Event, there are many more predefined for usage like this
    onClick(event) {
        console.log("app-examle clicked", event)
    }
    
    // Activate Mutations Observer
    onMutation(mutationRecord) {
        console.log(mutationRecord)
    }
})

define(AppExample)

./js/main.js

Let the browser know your application.

import "./apps/example.js"

Or:

import { AppExample } from "./apps/example.js"
let body = document.querySelector("body")
body.appendChild(new AppExample())

./index.html

Import your application into the DOM.

...
<body>
    <app-example></app-example>
</body>
...
1.1.0

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago