0.5.1 • Published 5 months ago

@marko-tags/subscribe v0.5.1

Weekly downloads
58
License
MIT
Repository
github
Last release
5 months ago

Add and remove event subscriptions within your template.

Installation

npm install @marko-tags/subscribe

Example

class {
    onCreate() {
        this.state = {
            listening: false
        }
    }

    toggle() {
        this.state.listening = !this.state.listening;
    }

    handleMove(e) {
      ...
    }
}

<button on-click('toggle')>
  <if(state.listening)>
    <!-- Only logs mouse moves if we are in the listening state -->
    <subscribe to=window on-mousemove('handleMove')/>
    Stop Listening
  </if>
  <else>
    Listen
  </else>
</button>

API

<subscribe
  to=EventEmitter|EventTarget
  on-*(string, ...args)
  once-*(string, ...args)/>
0.5.0

5 months ago

0.5.1

5 months ago

0.4.4

12 months ago

0.4.3

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.0

6 years ago

0.1.0

6 years ago

0.0.0

6 years ago