:) Unsubscribe para Pros and Juniors 💪 💨
Problema
English 👳
When you subscribe to an observable or event in JavaScript, you needto unsubscribe to release memory in the system when you finish to use it. Otherwise, you will have a memory leak.
Português 😁
Quando você se inscrever em um evento observável ou em JavaScript, será necessário cancelar a assinatura da memória do sistema quando terminar de usá-lo. Caso contrário, você terá um vazamento de memória.
AutoLeave() 😁
English.
Class decorator that will automatically unsubscribe from observable subscriptions when the component is destroyed .
PT.
Decorador de classe que irá automaticamente cancelar os observáveis quando o componente for destruído e não só .
Installation ⚡️
npm install ngx-leave --save
AutoLeave
; @@ implements OnInit OnDestroy um$: Subscription; tree$: Subscription; { } { thisum$ = ; thistree$ = ; } // This method need to be implemented { }
Option | description | default |
---|---|---|
subscriptions |
array all name of subscription | [] |
arrayName |
name variable with subscription name | '' |
method |
function name to lib call | ngOnDestroy |
Nota: subscriptions
will be ignore if you set a value on arrayName
.
@AutoLeave({subscriptions: ['um$','tree$']})
Leave
;
Option
Leave(this,functionName);
Usando em uma class
;
We test 💕 💞
Ação | Descrição |
---|---|
Test Suite |
4 passed, 4 total |
Tests |
17 passed, 17 total |
Snapshots |
0 total |
Time |
6.129s |
Ran all test suites |
Obrigado / Thanks 👊 👊 ✊ ✌️
All Devs 👽 😂😂