Class: kb.Store

Defined in: src/core/store.coffee

Variables Summary

instances =
[]

Class Method Summary

Instance Method Summary

Class Method Details

. (void) useOptionsOrCreate(options, obj, observable)

Used to either register yourself with the existing store or to create a new store.

Examples:

kb.Store.useOptionsOrCreate(model, this, options);

Parameters:

  • options ( Object ) please pass the options from your constructor to the register method. For example, constructor(model, options)
  • obj ( Instance ) the instance that will own or register with the store
  • observable ( ko.observable ) the observable that will own the store

Constructor Details

# (void) constructor()

Used to create a new kb.Store.

Instance Method Details

# (void) destroy()

Required clean up function to break cycles, release view models, etc. Can be called directly, via kb.release(object) or as a consequence of ko.releaseNode(element).

# (void) clear()

Manually clear the store

# (void) compact()

Manually compact the store by searching for released view models

# (void) retain(observable, obj, creator)

Used to register a new view model with the store.

Examples:

retain an observable with the store

store.retain(observable, obj, creator);

Parameters:

  • obj ( Model ) the Model
  • observable ( ko.observable ) the observable to share for the Model
  • options ( Object ) please pass the options from your constructor to the register method. For example, constructor(model, options)

Options Hash: (options):

  • creator ( Constructor|Function ) the constructor or function used to create the observable. It is used to match observables in the store.
  • path ( String ) the path to the value (used to create related observables from the factory).
  • store ( kb.Store ) a store used to cache and share view models.
  • factory ( kb.Factory ) a factory used to create view models.

# (void) retainOrCreate(obj, options, deep_retain)

Used to find an existing observable in the store or create a new one if it doesn't exist.

Examples:

register an observable with the store

observable = store.retainOrCreate(value, {path: kb.utils.wrappedPath(observable), factory: kb.utils.wrappedFactory(observable)})

Parameters:

  • obj ( Model|Collection|Data ) the object to create the observable for. Only Models are cached in the store.
  • options ( Object ) please pass the options from your constructor to the register method. For example, constructor(model, options)
  • deep_retain ( boolean ) setting to true retains an existing observable when found.

Options Hash: (options):

  • creator ( Constructor|Function ) the constructor or function used to create the observable. It is used to match observables in the store.
  • path ( String ) the path to the value (used to create related observables from the factory).
  • store ( kb.Store ) a store used to cache and share view models.
  • factory ( kb.Factory ) a factory used to create view models.

# (void) release(observable, force)

Release a reference to a a ViewModel in this store.

    Quickly fuzzy find classes, mixins, methods, file:

    Control the navigation frame:

    You can focus and blur the search input: