import { UserService } from './user.service'; import { LocalStorageService } from './local-storage.service'; import { Observable, ReplaySubject } from 'rxjs'; import { ApiConnectionService } from './api-connection.service'; /** * The WasDataService. * * ```typescript * // Import in any component this is to be used: * import { WasDataService } from 'WickeyAppStore'; * * // Inject it in the constructor * constructor(wasDataService: WasDataService) { } * * // Restore from cloud/local. * // NOTE: Can pass in a save conflict mapping function that returns the desired save to keep. * // onSaveConflict(localSave: any, cloudSave: any) => any * this.wasDataService.restore().subscribe(mydata => {}) * * // Persist to cloud. * this.wasDataService.persist(); * * // Save a value (where value is json stringifiable). * this.wasDataService.save('key', 'value'); * * // Get a value from db. * this.wasDataService.get('key'); * * // Delete a value from db. * this.wasDataService.del('key'); * * // listen for data observable. * this.wasDataService.data.subscribe(mydata => {}); * ``` */ export declare class WasDataService { private apiConnectionService; private userService; private localStorageService; private _data; private _dataObj; /** Set to true if WasDataService is being/has been used in app. */ isUsed: boolean; /** @ignore */ constructor(apiConnectionService: ApiConnectionService, userService: UserService, localStorageService: LocalStorageService); private _updateDataStore; /** * Pushes saved data to all subscribers on every change update. * * @example * Use in angular template with the `async` pipe * wasDataService.data | async * Subscribe in ts: wasDataService.data.subscribe * * @readonly */ get data(): ReplaySubject; /** * Loads the store from localStorage. * @ignore */ private loadLocalStore; /** load locally, then from server. * @ignore */ private initLoad; /** * Map/Filter function. If local save and cloud save both exist, choose which one to keep. * * @param localSave Local save. * @param cloudSave Cloud save. */ private _resolveSaveConflict; /** * Restores/Returns the data from the cloud or local db whichever has a newer timestamp. * * NOTE: The data will be in key/val format where val is can be anything json stringifiable * * @param [resolveSaveConflict] Map/Filter function. * If local save and cloud save both exist, choose which one to keep. NOTE: Default: newer copy is chosen. */ restore(resolveSaveConflict?: (localSave: any, cloudSave: any) => any): Observable; /** * Persists your save data to the cloud. * NOTE: please use sparingly, it can be subject to rate limits. */ persist(): Observable; /** @ignore */ private beforeunloadHandler; /** * Save a value. * NOTE: Where value is json stringifiable. * * @param _key The key. * @param _val The Value (where value is json stringifiable). */ save(_key: string, _val: any): void; /** * Load a value from db. * * @param _key The key. */ load(_key: string): Observable; /** * Get a value from db. * * @param _key The key. */ get(_key: string): any | null; /** * Delete a key/value from db. * * @param _key The key. */ del(_key: string): boolean; /** * Get cloud data packet. * @ignore */ private getCloudStore; /** * Set data in the key val store. * @ignore */ private setCloudStore; /** * Delete value(s) from key val store. * @ignore */ private deleteCloudStore; } //# sourceMappingURL=was-data.service.d.ts.map