material 0.9.10 → 0.9.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/class/view.js +25 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "material",
3
- "version": "0.9.10",
3
+ "version": "0.9.11",
4
4
  "description": "A lightweight implementation of Material Design Components for the web - ES6",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/class/view.js CHANGED
@@ -1,12 +1,32 @@
1
- import Control from './control'
1
+ import Component from './component'
2
+ import events from '../module/events'
2
3
 
3
- class View extends Control {
4
- static default = {
5
- base = 'view'
6
- }
4
+ class View extends Component {
5
+ static base = 'view'
7
6
 
8
7
  constructor (options) {
9
8
  super(options)
9
+ this.events = {}
10
+
11
+ if (this.options.events) {
12
+ events.attach(this.options.events, this)
13
+ }
14
+ }
15
+
16
+ on (event, listener) {
17
+ if (!this.events[event]) {
18
+ this.events[event] = []
19
+ }
20
+ this.events[event].push(listener)
21
+
22
+ return this
23
+ }
24
+
25
+ emit (event, ...args) {
26
+ if (this.events[event]) {
27
+ this.events[event].forEach(listener => listener.apply(this, args))
28
+ }
29
+ return this
10
30
  }
11
31
  }
12
32