1.0.6 • Published 6 months ago

@trellisorg/use-memo v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

@trellisorg/use-memo

Memoization functionality for Angular components, directives and services.

Demo

Clone the repo and run: yarn nx serve use-memo-demo

Install

yarn yarn add @trellisorg/use-memo

npm npm i @trellisorg/use-memo --save

Usage

import { ChangeDetectorRef, Component, inject } from '@angular/core';
import { useMemo } from '@trellisorg/use-memo';

@Component({
    selector: 'trellisorg-root',
    template: ` <div>{{ message() }}</div> `,
})
export class AppComponent {
    readonly message = useMemo(() => {
        // Will only be logged the first time, every subsequent change detection cycle is cached
        console.log('Returning hello world');
        return 'Hello World';
    });

    constructor() {
        const ref = inject(ChangeDetectorRef);

        setInterval(() => {
            ref.detectChanges();
        }, 1000);
    }
}
1.0.6

6 months ago

1.0.5

1 year ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago