Url Persistence Strategy

Edit on GitHub

This document explains the Url Persistence Strategy service in the Components Library.

Overview

Url Persistence Strategy is an Angular Service that uses browser URL to store the data.

Check out an example usage of the Url Persistence Strategy.

Service configuration:

  • storage - persistence strategy type.
<spy-select
    [datasource]="{
        type: 'http',
        ...,
        cache: {
            ...,
            storage: 'url',
        },
    }"
>
</spy-select>

Service registration

Register the service:

@NgModule({
    imports: [
        PersistenceModule.withStrategies({
            'url': UrlPersistenceStrategy,
        }),
    ],
})
export class RootModule {}

Interfaces

Below you can find interfaces for the Url Persistence Strategy:

declare module '@spryker/persistence' {
    interface PersistenceStrategyRegistry {
        'url': UrlPersistenceStrategy;
    }
}

interface UrlPersistenceStrategy extends PersistenceStrategy {
    save(key: string, value: unknown): Observable<void>;
    retrieve<T>(key: string): Observable<T | undefined>;
    remove(key: string): Observable<void>;
}