JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 51
  • Score
    100M100P100Q79506F
  • License MIT

Small mixin for LitElement to get easy change events via the properties getter

Package Exports

  • @morbidick/lit-element-notify
  • @morbidick/lit-element-notify/lit-element-notify.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@morbidick/lit-element-notify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Change notification mixin for LitElement

npm version

Small mixin for LitElement to get easy change events via the properties getter.

Install

npm install @morbidick/lit-element-notify

Usage

import { LitElement, html } from '@polymer/lit-element/lit-element.js';
import notify from '@morbidick/lit-element-notify/lit-element-notify.js';

class notifyingElement extends notify(LitElement) {
  static get properties() {
    return {

      // property names get lowercased and the -changed suffix is added
      token: {
        type: String,
        notify: true, // fires token-changed
      },
      camelCase: {
        type: String,
        notify: true, // fires camelcase-changed
      },

      // an explicit event name can be set
      thing: {
        type: String,
        notify: 'success-event', // fires success-event
      },

      // if an attribute value is set, -changed is appended 
      anotherProperty: {
        type: String,
        attribute: 'another-attribute',
        notify: true, // fires another-attribute-changed
      },
    };
  }
}