API Docs for: trial
Show:

nx.data.CollectionRelation Class

Module: nx.data

Prepare a calculation provider for a map of collections.

Constructor

nx.data.CollectionRelation

(
  • map
)

Parameters:

  • map Object/Map

    A map indicates names of the collection for calculation.

Item Index

Methods

Methods

and

(
  • target
  • sources
)
static

Affect target to be the equivalent collection of the first empty collection or the last collection. Release object could stop the dependencies.

Parameters:

  • target Collection
  • sources Array of Collection

Returns:

an object with release method

buildExpressionTree

(
  • tokens
)
Array tree static

Build a tree of expresson syntax with the expression tokens. e.g. tokens ["A", "|", "B", "&", "(", "C", "&", "D", ")"], which was separated from expression "A | B & (C | D)", will be separated into [|, A, [&, B, [|, C, D]]], because '&' has higher priority than '|', and braced "C | D" has higher priority than &.

Similar to the priorities in JavaScript:

operatorfunctionality
()braces
-complement
&cross
^symmetric difference
|union
&&and (the first empty collection or the last collection)
||or (the first non-empty collection)

Parameters:

  • tokens Array of token

Returns:

Array tree:

Parsed syntax tree of the expression tokens.

calculate

(
  • target
  • expression
)

Apply a inter-collection releation to a collection. Supported operators:

OperatorCalculationMethod
&Sets crosscross
|Sets unionunion
^Sets symmetric differencedelta
-Sets complementcomplement
&&Sets logical andand
||Sets logical oror
Tips:
  • Logical and means 'first empty collection or last collection'
  • Logical or means 'first non-empty collection or last collection'

Parameters:

  • target Collection

    The target collection.

  • expression String

    The relation expression.

Returns:

An object with release method.

complement

(
  • target
  • sources
)
static

Affect target to be the complement collection of sources collections. Release object could stop the dependencies.

Parameters:

  • target Collection
  • sources Array of Collection

Returns:

an object with release method

cross

(
  • target
  • sources
)
static

Affect target to be the cross collection of sources collections. Release object could stop the dependencies.

Parameters:

  • target Collection
  • sources Array of Collection

Returns:

an object with release method

delta

(
  • target
  • sources
)
static

Affect target to be the symmetric difference collection of sources collections. Release object could stop the dependencies. The name 'delta' is the symbol of this calculation in mathematics.

Parameters:

  • target Collection
  • sources Array of Collection

Returns:

an object with release method

getCollectionSyncMonitor

(
  • collection
  • sync
)
Function<item>

This util returns a monitor function of ObservableCollection, which is used to synchronize item existance between 2 collections.

Parameters:

  • collection Object

    The target collection to be synchronized.

  • sync Object
    • If true, make sure target collection will have all items as source collection has;
    • If false, make sure target collection will not have any item as source collection has.
    Default true.

Returns:

Function<item>:

The monitor function.

or

(
  • target
  • sources
)
static

Affect target to be the equivalent collection of the first non-empty collection. Release object could stop the dependencies.

Parameters:

  • target Collection
  • sources Array of Collection

Returns:

an object with release method

union

(
  • target
  • sources
)
static

Affect target to be the union collection of sources collections. Release object could stop the dependencies.

Parameters:

  • target Collection
  • sources Array of Collection

Returns:

an object with release method