Home Reference Source
import DirectorySubject from 'vibejs/src/directory/DirectorySubject.js'
public class | source

DirectorySubject

Constructor Summary

Public Constructor
public

constructor(directory: Directory, store: EntityStore)

Create DirectorySubject

Member Summary

Public Members
public

Attached Directory

public

Reactive interface which contains mutations, computed values and evaluated state

public

Observable, updated each time directory state is changed

Private Members
private

_store: *

Attached EntityStore

private

[model name][entity id] like structure of subscriptions

Method Summary

Public Methods
public

asObject(relationDeepness: number): Object

public

isSubscriberOf(name: string, id: *): Boolean

public

mutate(mutation: Object, message: string)

Mutate directory state

public

subscribe(name: stirng, id: *): Function

Prepares to subscribe Will rewrite previous subscription

public

unsubscribe(name: string, id: *)

Unsubscribe from entity updates and delete subscription

public

update()

Force update observable

public

Force update interface

Private Methods
private

Insert computed values into item(reactive interface or evaluated state)

private

_applyMutations(reactiveInterface: Object)

Insert mutation functions into reactiveInteface

private

_asObject(structure: Object, item: Object, deepness: number): *

Writes evaluated state into item from structure

private
private

_mapObserverToSource(item: Object, structure: Object, stateProvider: Object)

Define reactive getters and setters

Public Constructors

public constructor(directory: Directory, store: EntityStore) source

Create DirectorySubject

Params:

NameTypeAttributeDescription
directory Directory
store EntityStore

Public Members

public directory: * source

Attached Directory

public interface: * source

Reactive interface which contains mutations, computed values and evaluated state

public observable: * source

Observable, updated each time directory state is changed

Private Members

private _store: * source

Attached EntityStore

private _subscriptions: {} source

[model name][entity id] like structure of subscriptions

Public Methods

public asObject(relationDeepness: number): Object source

Params:

NameTypeAttributeDescription
relationDeepness number

how deep to resolve relationships

Return:

Object

evaluated javascript object

public isSubscriberOf(name: string, id: *): Boolean source

Params:

NameTypeAttributeDescription
name string

model name

id *

entity id

Return:

Boolean

is this subject is subscriber of passed entity

public mutate(mutation: Object, message: string) source

Mutate directory state

Params:

NameTypeAttributeDescription
mutation Object

payload

message string

commit message

public subscribe(name: stirng, id: *): Function source

Prepares to subscribe Will rewrite previous subscription

Params:

NameTypeAttributeDescription
name stirng

model name

id *

entity id

Return:

Function

real subscribe function

public unsubscribe(name: string, id: *) source

Unsubscribe from entity updates and delete subscription

Params:

NameTypeAttributeDescription
name string

model name

id *

entity id

public update() source

Force update observable

public updateInterface() source

Force update interface

Private Methods

private _applyComputed(item: Object) source

Insert computed values into item(reactive interface or evaluated state)

Params:

NameTypeAttributeDescription
item Object

private _applyMutations(reactiveInterface: Object) source

Insert mutation functions into reactiveInteface

Params:

NameTypeAttributeDescription
reactiveInterface Object

private _asObject(structure: Object, item: Object, deepness: number): * source

Writes evaluated state into item from structure

Params:

NameTypeAttributeDescription
structure Object

structure

item Object

object to write to

deepness number

how deep to resolve relationships

Return:

*

private _createReactiveInterface(): Object source

Return:

Object

reactive interface

private _mapObserverToSource(item: Object, structure: Object, stateProvider: Object) source

Define reactive getters and setters

Params:

NameTypeAttributeDescription
item Object

object to write to

structure Object

structure

stateProvider Object

get by key and set by key and value helper