1.0.2 • Published 3 years ago

@agape/rxjs v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

@agape/rxjs

Companion library for rxjs

Synopsis

import { tie } from '@agape/rxjs';
import { timer } from 'rxjs';

class Foo {
    constructor( ) {
        tie( this, 'destroy', 
            timer(1000).subscribe( n => console.log(n) )
        )
    }

    destroy() {
        console.log( "Destroying foo" )
    }
}

const o = new Foo()
setTimeout( () => o.destroy(), 10000)

Description

Provides the tie function which can be used to unsubscribe from rxjs subscriptions when a specified method is called.

Functions

tie (target, methodName, ...subscriptions)

Tie subscriptions to a specified object and method call.

Angular Example

Prevent memory leaks by clearing the tied subscriptions when a component is destroyed.

import { tie } from '@agape/rxjs';
import { timer } from 'rxjs';

@Component( ... )
class FooComponent {
    ngOnInit( ) {
        tie( this, 'ngOnDestroy', 
            timer(1000).subscribe( n => console.log(n) )
        )
    }
}

Author

Maverik Minett maverik.minett@gmail.com

Copyright

© 2022 Maverik Minett

License

MIT

1.0.2

3 years ago

1.0.1

3 years ago

0.1.25

3 years ago

0.1.24

3 years ago

0.1.23

3 years ago

0.1.22

3 years ago

0.1.21

3 years ago

0.1.20

3 years ago

1.0.0

3 years ago

0.1.19

3 years ago

0.1.16

3 years ago

0.1.14

3 years ago

0.1.13

3 years ago

0.1.12

3 years ago

0.1.11

3 years ago

0.1.10

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago