Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin
Section
Column
width50%

ChangeApplier API

This section explains and documents the various Javascript API calls for instantiating and working with ChangeAppliers.

Instantiating a ChangeApplier

Instantiating a ChangeApplier is extremely simple.

Code Block
javascript
javascript
var applier = fluid.makeChangeApplier(model);
Code Block
javascript
javascript
var applier = fluid.makeChangeApplier(model, options);

Please see Options below for more information about the new options parameter. Note that this new parameter is independent of the new Transaction support (which also uses options).

The makeChangeApplier call takes a single argument, which is the model object (the root of a tree of plain Javascript objects) to which this applier is to be attached. Note that by standard model semantics, whilst any subobjects and properties under this tree can and will change asynchronously, the essential identity of this model tree is defined by this exact object handle model. Therefore to establish agreement amongst model citizens and appliers about which model is being talked about, this object handle must be preserved, whatever happens to the object tree beneath it. The Fluid base framework contains various utility functions which help to make this easy - for example

Code Block
javascript
javascript
fluid.clear(model);

is a call which unlinks all properties from the supplied model, preparing it for a wholesale change. A corresponding useful call is

Code Block
javascript
javascript
fluid.model.copyModel(model, newModel)
Column
solid
Panel
borderStyle
borderColor#566b30
bgColor#fff
titleBGColor#D3E3C4
borderStylesolid
titleOn This Page
Table of Contents
toc
maxLevel
5
minLevel2
maxLevel5
Panel
borderColor#321137
bgColor#fff
titleBGColor#c1b7c3
borderStylesolid
titleSee Also
borderStylesolid
Include Page
Still Need Help panel
Still Need Help panel

...

Name

Description

Values

Default

cullUnchanged

This option allows users to configure a ChangeApplier to not fire a modelChanged event if a change request doesn't, in fact, modify the model.

boolean

false

{htmlcomment} h2. Working with composite models An extremely useful affordance of Fluid's "transparent" model for models, is that these may participate very straightforwardly in aggregation. Models may even at one time be part of multiple, perhaps "ad hoc" assemblages of models into wider address spaces, or
Wiki Markup
HTML Comment

Working with composite models

An extremely useful affordance of Fluid's "transparent" model for models, is that these may participate very straightforwardly in aggregation. Models may even at one time be part of multiple, perhaps "ad hoc" assemblages of models into wider address spaces, or "super-models"

-

since

their

update

and

read

semantics

are

clear

and

uniform,

they

need

no

special

notification

or

modification

of

their

role.

All

that

is

required

is

that

updates

are

properly

routed

through

the

particular

ChangeApplier

instance

which

is

attached

to

them.

In

order

to

help

in

the

task

of

creating

these

model

assemblages,

{{

DataBinding.js

}}

includes

a

dedicated

call

{{

fluid.assembleModel

}}

:

{

Code Block
:
javascript
}
javascript

fluid.assembleModel(modelSpec)
{code} {{modelSpec}} is a model specification object, which consists of a map of path keys to records {{model, applier}}, for example: {code:javascript}

modelSpec is a model specification object, which consists of a map of path keys to records model, applier, for example:

Code Block
javascript
javascript

{
"path1": {
    model: subModel1,
    applier: subApplier1
    },
"path2": {
    model: subModel2,
    applier: subApplier2
    }
}
{code}

represents

a

{{

modelSpec

}}

object,

where

{{

subModel1

}}

,

{{

subModel2

}}

are

two

different

models,

and

{{

subApplier1

}}

and

{{

subApplier2

}}

are

two

appliers

which

have

been

attached

to

them.

The

return

value

from

{{

assembleModel

}}

is

a

fresh

{{

model,

applier

}}

pair

which

is

ready

for

further

aggregation.

Note

that

such

a

"super-Applier"

only

fulfils

a

"reduced

contract"

-

the

only

one

of

the

ChangeApplier

methods

it

supports

is

{{

fireChangeRequest

}}

-

any

other

methods

(adding

and

removing

listeners,

etc.)

must

be

targetted

at

the

original

individual

appliers.

However,

the

"reduced

contract"

is

sufficient

for

passing

the

ChangeApplier

in

to

an

application

of

the

[

Fluid

Renderer

|Infusion13:Fluid Renderer - Background]

in

"autoBind"

mode.

{htmlcomment}

Anchor
transactional
transactional

...