0.1.27 • Published 5 years ago

ngx-component-mixins v0.1.27

Weekly downloads
7
License
MIT
Repository
github
Last release
5 years ago

NGX Component Mixins

CircleCI

Overview

A collection of useful mixins for use in creating Angular Components

Resizable Mixin

This mixin will automatically trigger a resize method whenever the user's browser changes size

    class MyComponent extends ResizableMixin(BaseMixin) {
        doRezize({ w, h }) {
            console.log('My component's is now W wide and H high
        }
    }

Subscriber Mixin

This mixin provides automated unsubscription to Observables when a component is destroyed

    class MyComponent extends SubscriberMixin(BaseMixin) {
        doThing() {
            this.subscribeTo(someObservable, () => {
                // Do what you want
            })
        }
    }

It also provides a nice shorthand for taking just ONE event from an Observable and converting it into a Promise

    class MyComponent extends SubscriberMixin(BaseMixin) {
        doThing() {
            this.when(someObservable)
                .then(() => {
                    // Do what you want
                })
                .catch(() => {
                    // Handle the error
                })
        }
    }

Dynamic Mixin

This mixin adds the concept of TIME to the component

The component can be STARTED and STOPPED and whilst RUNNING it will TICK for each moment in time

    class MyComponent extends DynamicMixin(BaseMixin) {
        onClickPlay() {
            this.doStart()
        }
        
        onClickStop() {
            this.doStop()
        }
        
        doTick() {
            // Do whatever you want each tick of the clock
        }
    }
0.1.27

5 years ago

0.1.26

5 years ago

0.1.25

5 years ago

0.1.24

5 years ago

0.1.23

5 years ago

0.1.22

5 years ago

0.1.21

5 years ago

0.1.20

5 years ago

0.1.19

5 years ago

0.1.18

5 years ago

0.1.17

5 years ago

0.1.16

5 years ago

0.1.15

5 years ago

0.1.14

5 years ago

0.1.13

5 years ago

0.1.12

5 years ago

0.1.11

5 years ago

0.1.10

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago