• Sync class property with persistent storage (LocalStorage by default)

    Type Parameters

    • T

    Parameters

    Returns ((target: any, prop: any) => void)

    Decorator function

      • (target, prop): void
      • Parameters

        • target: any
        • prop: any

        Returns void

    class ThemeEngine {
    @persist({default: 'os'}) current!: string;
    }

    const theme = new ThemeEngine();
    console.log(theme.current) // Output: os

    theme.current = 'light'; //Any changes will be automatically saved to localStorage

    location.reload(); // Simulate refresh
    console.log(theme.current) // Output: light