1.0.25 • Published 3 years ago

ember-lifecycle-component v1.0.25

Weekly downloads
181
License
MIT
Repository
github
Last release
3 years ago

ember-lifecycle-component

For situations where you don't need a template.

  • WebGL Integration
  • Other DOM-less situations

The LifeCycleComponent has the same interface as @glimmer/component, but with some additional hooks.

Generally, you do not need this. Nearly all side-effecting code can be represented as computed/tracked properties and regular getters while causing changes via the functions that would have started the side-effect anyway.

All the hooks available for use are:

  • constructor(owner, args)
  • didReceiveArgs(prev, next)
  • didUpdate()
  • willDestroy()

Installation

ember install ember-lifecycle-component

Usage

More examples here, in the tests

import { LifeCycleComponent } from 'ember-lifecycle-component';

import THREE from 'three';

let geometry = new THREE.BoxGeometry( 2, 2, 2 );
let material = new THREE.MeshNormalMaterial();

export default class SceneBoxComponent extends LifeCycleComponent {
  constructor(owner, args) {
    super(owner, args);

    this.mesh = new THREE.Mesh(geometry, material);

    let { rx, ry, rz } = this.args;

    this.#updateRotation(rx, ry, rz);
    this.mesh.position.set(0, 0, 0);

    args.scene.add(this.mesh);
  }

  didUpdate() {
    let { rx, ry, rz } = this.args;
    this.#updateRotation({ rx, ry, rz });
  }

  willDestroy() {
    this.args.scene.remove(this.mesh);
  }

  #updateRotation({ rx, ry, rz }) {
    this.mesh.rotation.set(rx, ry, rz);
  }
}

Compatibility

  • See: config/ember-try.js

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

1.0.25

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.7.1

3 years ago

0.7.0

4 years ago

0.6.0

4 years ago

0.4.0

4 years ago