Module

tracking

// Unminified
import { tracked } from 'https://fancy-pants.js.org/tracking.js';

// Minified
import { tracked } from 'https://fancy-pants.js.org/min/tracking.js';

This is the auto-tracking system and a use case for scheduleRender.

View Source tracking.js, line 1

Classes

Cache
Tracked

Methods

# static activateTracking(owner) → {Object}

This is how all tracked properties are converted from the place holder TrackedProperty object into actual tracked getter/setters. Any object that uses tracked must be passed through activateTracking otherwise the properties are useless.

Parameters:
Name Type Description
owner Object

the object to search and replace any Tracked objects.

See:

View Source tracking.js, line 338

the same owner object passed in to support chaining

Object
Examples
class Foo {
  bar = tracked();
}
let foo = activateTracking(new Foo());
foo.bar = 'BAR'; // will trigger a render (becomes dirty)
let obj = activateTracking({ bar: tracked('FOO') });
foo.bar = 'BAR'; // will trigger a render (becomes dirty)

# static memoizeFunction(fn) → {function}

Wrap a function to be memoized based on the auto-tracking system.

Parameters:
Name Type Description
fn function

the function to memoized

View Source tracking.js, line 285

a memoized version of the function

function

# static setScheduleRerender(callback)

Register a function to be called when a Tracked instance is dirtied. There can only be one. This is not used when working with the renderer or Component class as they mange this for you.

You would only use this if you were interfacing with this module on your own.

Parameters:
Name Type Description
callback function

the function to call when tags are dirtied

View Source tracking.js, line 276

# static tracked(initialValueopt) → {Tracked}

Create a Tracked instance.

Parameters:
Name Type Attributes Description
initialValue any <optional>
See:

View Source tracking.js, line 311

Tracked
Examples
class Foo {
  bar = tracked();
}
let foo = new Foo();
foo.bar.revision; // 0
foo.bar.value = 'BAR';
foo.bar.revision; // 1
let foo = { bar: tracked('FOO') };
foo.bar.revision; // 0
foo.bar.value = 'BAR';
foo.bar.revision; // 1