Home Reference Source
public class | source

Persist

You can directly use an instance of this class. persist

Extends:

fbemitter~EventEmitter → Persist

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
public
public

costTab: *

public
public
public
public
public
public
public
public
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

Removes the comparison from localstorage.

public

Get all saved data and settings

public

getBuild(shipId: String, name: String): String

Get the serialized code/string for a build.

public

getBuilds(shipId: String): Object | Array

Get all builds (object) or builds for a specific ship (array)

public

Get an array of all builds names for a ship

public

Get the saved Mats per grade

public

Get a comparison

public

Get all saved comparisons

public

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

hasBuild(shipId: String, name: String): Boolean

Check if a build has been saved

public

Check if any builds have been saved

public

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

saveBuild(shipId: String, name: String, code: String)

Persist a ship build in local storage.

public

saveComparison(name: String, builds: array, facets: array)

Persist a comparison in localstorage.

public

setCmdr(cmdrName: string)

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

Persist selected outfitting tab

public

setRolls(matsPerGrade: Object)

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

setState(state: Object)

Save the current router state to localstorage

public

Show module resistances setting

public

Show tooltips setting

Public Constructors

public constructor() source

Create an instance

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 deleteAll() source

Delete all builds and comparisons from localStorage

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

Params:

NameTypeAttributeDescription
shipId String

The unique id for a model of ship

name String

The name of the build

public deleteComparison(name: String) source

Removes the comparison from localstorage.

Params:

NameTypeAttributeDescription
name String

Comparison name

public getAll(): Object source

Get all saved data and settings

Return:

Object

Data and settings

public getBuild(shipId: String, name: String): String source

Get the serialized code/string for a build. Returns null if a build is not found.

Params:

NameTypeAttributeDescription
shipId String

The unique id for a model of ship

name String

The name of the build

Return:

String

The serialized build string.

public getBuilds(shipId: String): Object | Array source

Get all builds (object) or builds for a specific ship (array)

Params:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
shipId String

Ship Id

Return:

Array

Array of string or empty array

public getCmdr(): Object source

Get the saved Mats per grade

Return:

Object

of rolls per grade

public getComparison(name: String): Object source

Get a comparison

Params:

NameTypeAttributeDescription
name String

Comparison name

Return:

Object

Object containing array of facets and ship id + build names

public getComparisons(): Object source

Get all saved comparisons

Return:

Object

All comparisons

public getCostTab(): number source

Get the saved discount

Return:

number

val Discount value/amount

public getInsurance(): String source

Get the saved insurance type

Return:

String

The name of the saved insurance type of null

public getLangCode(): String source

Get the current language code

Return:

String

language code

public getModuleDiscount(): number source

Get the saved ship discount

Return:

number

val Discount value/amount

public getOutfittingTab(): string source

Get the current outfitting tab

Return:

string

the current outfitting tab

public getRolls(): Object source

Get the saved Mats per grade

Return:

Object

of rolls per grade

public getShipDiscount(): number source

Get the saved ship discount

Return:

number

val Discount value/amount

public getSizeRatio(): number source

Retrieve the last router state from local storage

Return:

number

size Ratio

public getState(): Object source

Retrieve the last router state from local storage

Return:

Object

state State object containing state name and params

public hasBuild(shipId: String, name: String): Boolean source

Check if a build has been saved

Params:

NameTypeAttributeDescription
shipId String

Ship Id

name String

Build name

Return:

Boolean

True if the build exists

public hasBuilds(): Boolean source

Check if any builds have been saved

Return:

Boolean

True if any builds have been saved

public hasComparison(name: String): Boolean source

Check if a comparison has been saved

Params:

NameTypeAttributeDescription
name String

Comparison name

Return:

Boolean

True if a comparison has been saved

public hasComparisons(): Boolean source

Check if any comparisons have been saved

Return:

Boolean

True if any comparisons have been saved

public isEnabled(): Boolean source

Check if localStorage is enabled/active

Return:

Boolean

True if localStorage is enabled

public onStorageChange(e: StorageEvent) source

Listen to storage changes from other windows/tabs and update accordingly

Params:

NameTypeAttributeDescription
e StorageEvent

Storage Event

public saveBuild(shipId: String, name: String, code: String) source

Persist a ship build in local storage.

Params:

NameTypeAttributeDescription
shipId String

The unique id for a model of ship

name String

The name of the build

code String

The serialized code

public saveComparison(name: String, builds: array, facets: array) source

Persist a comparison in localstorage.

Params:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
cmdrName string

Commander name for EDEngineer

public setCostTab(tabName: number) source

Persist selected cost tab

Params:

NameTypeAttributeDescription
tabName number

Cost tab name

public setInsurance(insurance: String) source

Persist selected insurance type

Params:

NameTypeAttributeDescription
insurance String

Insurance type name

public setLangCode(langCode: String) source

Update and save the current language

Params:

NameTypeAttributeDescription
langCode String

language code

public setModuleDiscount(moduleDiscount: number) source

Persist selected module discount

Params:

NameTypeAttributeDescription
moduleDiscount number

Discount value/amount

public setOutfittingTab(tabName: string) source

Persist selected outfitting tab

Params:

NameTypeAttributeDescription
tabName string

Cost tab name

public setRolls(matsPerGrade: Object) source

Get the saved ship discount

Params:

NameTypeAttributeDescription
matsPerGrade Object

of rolls per grade

public setShipDiscount(shipDiscount: number) source

Persist selected ship discount

Params:

NameTypeAttributeDescription
shipDiscount number

Discount value/amount

public setSizeRatio(sizeRatio: number) source

Save the current size ratio to localstorage

Params:

NameTypeAttributeDescription
sizeRatio number

Size ratio scale

public setState(state: Object) source

Save the current router state to localstorage

Params:

NameTypeAttributeDescription
state Object

State object containing state name and params

public showModuleResistances(show: boolean): boolean source

Show module resistances setting

Params:

NameTypeAttributeDescription
show boolean

Optional - update setting

Return:

boolean

True if module resistances should be shown

public showTooltips(show: boolean): boolean source

Show tooltips setting

Params:

NameTypeAttributeDescription
show boolean

Optional - update setting

Return:

boolean

True if tooltips should be shown