Persist
Extends:
Persist store / service for all user settings. Currently uses localstorage only Should be treated as a singleton / single instance should be used hence why the default export is an instance (see end of this file).
Constructor Summary
Public Constructor | ||
public |
Create an instance |
Member Summary
Public Members | ||
public |
builds: * |
|
public |
cmdrName: * |
|
public |
comparisons: * |
|
public |
costTab: * |
|
public |
insurance: * |
|
public |
langCode: * |
|
public |
matsPerGrade: * |
|
public |
|
|
public |
|
|
public |
|
|
public |
shipDiscount: * |
|
public |
sizeRatio: * |
|
public |
state: * |
|
public |
|
Method Summary
Public Methods | ||
public |
Delete all builds and comparisons from localStorage |
|
public |
deleteBuild(shipId: String, name: String) Delete a build from local storage. |
|
public |
deleteComparison(name: String) Removes the comparison from localstorage. |
|
public |
Get all saved data and settings |
|
public |
Get the serialized code/string for a build. |
|
public |
Get all builds (object) or builds for a specific ship (array) |
|
public |
getBuildsNamesFor(shipId: String): Array Get an array of all builds names for a ship |
|
public |
Get the saved Mats per grade |
|
public |
getComparison(name: String): Object Get a comparison |
|
public |
Get all saved comparisons |
|
public |
getCostTab(): number Get the saved discount |
|
public |
Get the saved insurance type |
|
public |
Get the current language code |
|
public |
Get the saved ship discount |
|
public |
Get the current outfitting tab |
|
public |
Get the saved Mats per grade |
|
public |
Get the saved ship discount |
|
public |
Retrieve the last router state from local storage |
|
public |
Retrieve the last router state from local storage |
|
public |
Check if a build has been saved |
|
public |
Check if any builds have been saved |
|
public |
hasComparison(name: String): Boolean Check if a comparison has been saved |
|
public |
Check if any comparisons have been saved |
|
public |
Check if localStorage is enabled/active |
|
public |
onStorageChange(e: StorageEvent) Listen to storage changes from other windows/tabs and update accordingly |
|
public |
Persist a ship build in local storage. |
|
public |
saveComparison(name: String, builds: array, facets: array) Persist a comparison in localstorage. |
|
public |
Persist cmdr name |
|
public |
setCostTab(tabName: number) Persist selected cost tab |
|
public |
setInsurance(insurance: String) Persist selected insurance type |
|
public |
setLangCode(langCode: String) Update and save the current language |
|
public |
setModuleDiscount(moduleDiscount: number) Persist selected module discount |
|
public |
setOutfittingTab(tabName: string) Persist selected outfitting tab |
|
public |
Get the saved ship discount |
|
public |
setShipDiscount(shipDiscount: number) Persist selected ship discount |
|
public |
setSizeRatio(sizeRatio: number) Save the current size ratio to localstorage |
|
public |
Save the current router state to localstorage |
|
public |
showModuleResistances(show: boolean): boolean Show module resistances setting |
|
public |
showTooltips(show: boolean): boolean Show tooltips setting |
Public Constructors
Public Members
public builds: * source
public cmdrName: * source
public comparisons: * source
public costTab: * source
public insurance: * source
public langCode: * source
public matsPerGrade: * source
public moduleDiscount: * source
public moduleResistancesEnabled: * source
public outfittingTab: * source
public shipDiscount: * source
public sizeRatio: * source
public state: * source
public tooltipsEnabled: * source
Public Methods
public deleteBuild(shipId: String, name: String) source
Delete a build from local storage. It will also delete the ship build collection if it becomes empty
public deleteComparison(name: String) source
Removes the comparison from localstorage.
Params:
Name | Type | Attribute | Description |
name | String | Comparison name |
public getBuild(shipId: String, name: String): String source
Get the serialized code/string for a build. Returns null if a build is not found.
public getBuilds(shipId: String): Object | Array source
Get all builds (object) or builds for a specific ship (array)
Params:
Name | Type | Attribute | Description |
shipId | String | Optional Ship Id |
Return:
Object | Array | Object if Ship Id is not provided |
public getBuildsNamesFor(shipId: String): Array source
Get an array of all builds names for a ship
Params:
Name | Type | Attribute | Description |
shipId | String | Ship Id |
public getComparison(name: String): Object source
Get a comparison
Params:
Name | Type | Attribute | Description |
name | String | Comparison name |
public hasComparison(name: String): Boolean source
Check if a comparison has been saved
Params:
Name | Type | Attribute | Description |
name | String | Comparison name |
public onStorageChange(e: StorageEvent) source
Listen to storage changes from other windows/tabs and update accordingly
Params:
Name | Type | Attribute | Description |
e | StorageEvent | Storage Event |
public saveBuild(shipId: String, name: String, code: String) source
Persist a ship build in local storage.
public saveComparison(name: String, builds: array, facets: array) source
Persist a comparison in localstorage.
Params:
Name | Type | Attribute | Description |
name | String | The name of the comparison |
|
builds | array | Array of builds |
|
facets | array | Array of facet indices |
public setCmdr(cmdrName: string) source
Persist cmdr name
Params:
Name | Type | Attribute | Description |
cmdrName | string | Commander name for EDEngineer |
public setCostTab(tabName: number) source
Persist selected cost tab
Params:
Name | Type | Attribute | Description |
tabName | number | Cost tab name |
public setInsurance(insurance: String) source
Persist selected insurance type
Params:
Name | Type | Attribute | Description |
insurance | String | Insurance type name |
public setLangCode(langCode: String) source
Update and save the current language
Params:
Name | Type | Attribute | Description |
langCode | String | language code |
public setModuleDiscount(moduleDiscount: number) source
Persist selected module discount
Params:
Name | Type | Attribute | Description |
moduleDiscount | number | Discount value/amount |
public setOutfittingTab(tabName: string) source
Persist selected outfitting tab
Params:
Name | Type | Attribute | Description |
tabName | string | Cost tab name |
public setRolls(matsPerGrade: Object) source
Get the saved ship discount
Params:
Name | Type | Attribute | Description |
matsPerGrade | Object | of rolls per grade |
public setShipDiscount(shipDiscount: number) source
Persist selected ship discount
Params:
Name | Type | Attribute | Description |
shipDiscount | number | Discount value/amount |
public setSizeRatio(sizeRatio: number) source
Save the current size ratio to localstorage
Params:
Name | Type | Attribute | Description |
sizeRatio | number | Size ratio scale |
public setState(state: Object) source
Save the current router state to localstorage
Params:
Name | Type | Attribute | Description |
state | Object | State object containing state name and params |