@theredhead — Frontend Library - v1.0.0
    Preparing search index...

    Manages persisted saved searches through the application-wide StorageService (which defaults to localStorage via the STORAGE_STRATEGY injection token).

    Searches are stored as a JSON array under a key derived from the caller-supplied storageKey. Multiple independent search views can coexist by using different storage keys.

    private readonly savedSearchService = inject(SavedSearchService);

    // list
    const searches = this.savedSearchService.list('my-view');

    // save
    this.savedSearchService.save('my-view', {
    id: crypto.randomUUID(),
    name: 'Active users',
    descriptor: { junction: 'and', rules: [...] },
    savedAt: new Date().toISOString(),
    });

    // delete
    this.savedSearchService.remove('my-view', searchId);

    Override the STORAGE_STRATEGY token from @theredhead/lucid-foundation:

    providers: [
    { provide: STORAGE_STRATEGY, useClass: MyIndexedDbStrategy },
    ]
    Index

    Constructors

    Methods

    Constructors

    Methods

    • Remove all saved searches for a given storage key.

      Parameters

      • storageKey: string

      Returns void

    • Retrieve all saved searches for the given storage key.

      Returns an empty array when nothing is stored or when the stored value cannot be parsed.

      Parameters

      • storageKey: string

      Returns SavedSearch<unknown>[]

    • Remove a saved search by its id.

      No-op if the id does not exist.

      Parameters

      • storageKey: string
      • searchId: string

      Returns void

    • Persist a new ordering of saved searches.

      Accepts an array of IDs in the desired order. Searches whose IDs are not in the list are dropped.

      Parameters

      • storageKey: string
      • orderedIds: readonly string[]

      Returns void

    • Persist a saved search. If a search with the same id already exists it is replaced; otherwise the new search is appended.

      Parameters

      Returns void