New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

wtc-controller-element

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wtc-controller-element

Generic element controller. Binds an element to a controller.

latest
Source
npmnpm
Version
1.1.1
Version published
Maintainers
1
Created
Source

ElementController and ExecuteController

Install

$ npm install wtc-controller-element --save

ExecuteController

ExecuteController is a static class used to register and instanciate controllers extended from the ElementController class.

How to register a controller.

Inside your module, BEFORE exporting it:

// Register
ExecuteControllers.registerController(TestController, '[Name]');

As a convention, please use the name as the same name of the controller.

How to instanciate controllers.

There are 2 options, but first, import it:

import {ExecuteControllers}  from 'wtc-controller-element';
All at once

This will instanciate all elements with a [data-controller] attribute.

ExecuteControllers.instanciateAll();
Explicit

Just pass in the element and the name of the registered controller or the controller itself.

ExecuteControllers.instanciate(document.getElementById('id'), ['TestController'|TestController]);

ElementController

ElementController is the base class for controllers that alter DOM elements. It's responsible for saving the state and the instance of the controller for easy reference.

Usage

Import and extend it in your module.

import {default as ElementController, ExecuteControllers}  from 'wtc-controller-element';

class TestController extends ElementController {
  constructor(element) {
    super(element);
  }
}

/* Don't forget to register it */
ExecuteControllers.registerController(TestController, 'TestController');

bower

bower version is DEPRECATED and is here for older projects.
Please use the new ES6 module if possible.

Install

bower install wtc-controller-element

Usage

Simply extend it on your controller function.

Keywords

wtc

FAQs

Package last updated on 20 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts