Show:
Defined in: src/js/core/pro.js:9
Module: proact-core

ProAct.js turns plain JavaScript objects into holders of reactive properties. You can define the dependencies between these objects and properties using the 'vanilla' js syntax. For example if an object should have a property 'x', that depends on its two fields 'a' and 'b', the only thing that's needed is to define a function 'x', that refers to 'this.a' and 'this.b'.

So ProAct.js can turn every vanilla JavaScript value to a set of reactive properties, and this generates a dependency graph between them. The data flow in this oriented graph is determined by its edges. So if we should receive data from the outside of this dependency system we'll need a powerful but easy to use tool to turn every user or server generated action into a data event, common to the graph.

ProAct.js can be used to define bindings, to separate views from models (mv*), for performance optimizations... It is a tool. A powerful tool for creating other, high level tools, or applications. Everything should be defined in this namespace. It can be used as P or Pro.

ProAct is powerful Functional Reactive Programming (FRP) lib too. Its streams and events

are integrated with the reactive properties mentioned above. Everything can be described using declarative expressions. All ProAct classes and functions are defined in this namespace. You can use Pro and P instead of ProAct too.

Item Index

Methods

Properties

Methods

closed

() ProAct.Stream static

Provided by the proact-streams module.

Defined in src/js/streams/functions.js:83

Creates a closed ProAct.Stream.

Returns:

ProAct.Stream:

A closed ProAct.Stream instance.

fromCallback

(
  • callbackCaller
)
ProAct.Stream static

Provided by the proact-streams module.

Defined in src/js/streams/functions.js:307

Creates a ProAct.Stream, which emits the result of an action that uses a callback to notify that it is finished.

This can be used to create streams from http requests for example.

Example:

 var stream = ProAct.fromCallback(action);
 stream.on(function (v) {
   console.log(v);
 });

Parameters:

  • callbackCaller Function

    The action that receives a callback.

Returns:

fromEventDispatcher

(
  • target
  • eventType
)
ProAct.Stream static

Provided by the proact-streams module.

Defined in src/js/streams/functions.js:350

Creates a ProAct.Stream with source an evet emitter or dispatcher, it can be used with jQuery for example for example.

Example:

 var stream = ProAct.fromEventDispatcher($('.some-input'), 'keydown');
 stream.on(function (e) {
   console.log(e.which);
 });

Parameters:

  • target Object

    The event dispatcher, can be a jQuery button, or a DOM element, or somethnig like that.

  • eventType String

    The type of the event - for example 'click'.

Returns:

fromInvoke

(
  • interval
  • func
)
ProAct.Stream static

Provided by the proact-streams module.

Defined in src/js/streams/functions.js:258

The fromInvoke creates a ProAct.Stream, which emits the result of the passed func argument on every interval milliseconds.

If func returns closed the stream is closed.

Example:

   var stream = ProAct.fromInvoke(1000, function () {
     return 5;
   });
   stream.on(function (v) {
     console.log(v);
   });

   // After 1s we'll see '5' in the log, after 2s we'll see a second '5' in the log and so on...

Parameters:

  • interval Number

    The interval on which func will be called and its returned value will be triggered into the stream.

  • func Function

    The function to invoke in order to get the value to trigger into the stream.

Returns:

interval

(
  • interval
  • value
)
ProAct.Stream static

Provided by the proact-streams module.

Defined in src/js/streams/functions.js:132

Creates a ProAct.Stream, which emits the passed "value" over and over again at given time interval.

Example:

   var stream = ProAct.interval(1000, 7);
   stream.on(function (v) {
     console.log(v);
   });

  // This will print one number on every 1s and the numbers will be 7,7,7,7,7....

Parameters:

  • interval Number

    The time in milliseconds on which the value will be emitted.

  • value Object

    The value to emit.

Returns:

interval

(
  • interval
  • vals
)
ProAct.Stream static

Provided by the proact-streams module.

Defined in src/js/streams/functions.js:214

Creates a ProAct.Stream, which emits values of the passed vals array on the passed interval.

When every value is emitted through the stream they are emitted again and again and so on...

Example:

   var stream = ProAct.repeat(1000, [4, 5]);
   stream.on(function (v) {
     console.log(v);
   });

  // This will print one number on every 1s and the numbers will be 4 5 4 5 4 5 4 5 4 5 .. and so on

Parameters:

  • interval Number

    The time in milliseconds on which a value of the passed vals array will be emitted.

  • vals Array

    The array containing the values to be emitted on the passed interval.

Returns:

isProObject

(
  • value
)
Boolean

Provided by the proact-properties module.

Defined in src/js/properties/functions.js:54

Checks if the passed value is a valid ProAct.js object or not. ProAct.js object have a special __pro__ object that is hidden in them, which should be instance of ProAct.Core.

Parameters:

  • value Object

    The value to check.

Returns:

Boolean:

True if the value is object containing ProAct.Property instances and has a core.

N

()

No-action or emtpy function. Represent an action that does nothing.

prob

(
  • object
  • meta
)
Object static

The ProAct.prob method is the entry point for creating reactive values in ProAct.js

TODO More docs

Parameters:

  • object Object

    The object/value to make reactive.

  • meta Object | String

    Meta-data used to help in the reactive object creation.

Returns:

Object:

Reactive representation of the passed object.

proxy

(
  • object
  • target
  • meta
  • targetMeta
)
Object static

Provided by the proact-properties module.

Defined in src/js/properties/functions.js:5

The ProAct.proxy creates proxies or decorators to ProAct.js objects.

The decorators extend the target and can add new properties which depend on the extended ones.

Parameters:

  • object Object

    The object/value to make decorator to the target.

  • target Object

    The object to decorate.

  • meta Object | String

    Meta-data used to help in the reactive object creation for the proxy.

  • targetMeta Object | String

    Meta-data used to help in the reactive object creation for the target, if it is not reactive.

Returns:

Object:

Reactive representation of the passed object, decorating the passed target.

seq

(
  • interval
  • vals
)
ProAct.Stream static

Provided by the proact-streams module.

Defined in src/js/streams/functions.js:166

Creates a ProAct.Stream, which emits values of the passed vals array on the passed interval milliseconds.

When every value is emitted through the stream it is closed.

Example:

   var stream = ProAct.seq(1000, [4, 5]);
   stream.on(function (v) {
     console.log(v);
   });

  // This will print one number on every 1s and the numbers will be 4 5 and the stream will be closed.

Parameters:

  • interval Number

    The time in milliseconds on which a value of the passed vals array will be emitted.

  • vals Array

    The array containing the values to be emitted on the passed interval.

Returns:

stream

(
  • [subscribe]
  • [transformations]
  • source
  • queueName
)
ProAct.Stream static

Provided by the proact-streams module.

Defined in src/js/streams/functions.js:5

Creates a ProAct.Stream instance.

This method is capable of creating various source streams.

For example if the method is called like that:

 var stream = ProAct.stream();

A sourceless stream will be created, but it will be possible to invoke trigger* on it:

 stream.trigger(val);
 stream.triggerErr(new Error());
 stream.triggerClose();

The method can be called with a subscribe function too:

 var stream = ProAct.stream(function (source) {
   // ... logic using the source - the source is a stream, that has trigger/triggerErr/triggerClose
   $('.sel').on('click.myClick', function (e) {
     source.trigger(e);
   });

   return function () {
     // unsubscribing logic
     $('.sel').off('click.myClick');
   };
 });

So subscribe/unsubscribe to an even source can be programmed using this method.

The first argument can be a string too and if that's the case, ProAct.Stream's fromString method will be used for the stream construction.

Parameters:

  • [subscribe] String | Function optional

    Can be null for no subsbcribe functon, can function to be used for subscribtion to a source or can be string to use it with ProAct.Stream/fromString:method

  • [transformations] Array optional

    A list of transformation to be used on all incoming chages.

  • source ProAct.Actor

    A default source of the stream, can be null.

  • queueName String

    The name of the queue all the updates should be pushed to.

    If this parameter is null/undefined the default queue of flow is used.

    If this parameter is not a string it is used as the source.

Returns:

timeout

(
  • timeout
  • value
)
ProAct.Stream static

Provided by the proact-streams module.

Defined in src/js/streams/functions.js:97

Creates a ProAct.Stream, which emits the passed "value" once and then closes.

Example:

   var stream = ProAct.timeout(1000, 7);
   stream.on(function (v) {
     console.log(v);
   });

  // This will print '7' after 1s and will close.

Parameters:

  • timeout Number

    The time to wait (in milliseconds) before emitting the value and close.

  • value Object

    The value to emit.

Returns:

Properties

currentCaller

Object static

Provided by the proact-properties module.

Defined in src/js/properties/functions.js:68

Represents the current caller of a method, the initiator of the current action.

This property does the magic when for example an ProAct.AutoProperty is called for the first time and the dependencies to the other properties are created. The current caller expects to be used in a single threaded environment.

Do not remove or modify this property manually.

Default: null

flow

ProAct.Flow final

Provided by the proact-flow module.

Defined in src/js/flow/flow.js:401

The ProAct.Flow instance used by ProAct's property updates by default.

It defines only one queue - the default one proq.

Override this instance if you are creating a framework or toolset over ProAct.js.

registry

ProAct.Registry static

Provided by the proact-dsl module.

Defined in src/js/dsl/provider.js:582

The ProAct.Registry instance used by ProAct's by default.

It has a ProAct.Registry.StreamProvider registered on the s namespace.

It has a ProAct.Registry.ProObjectProvider registered on the po and obj namespaces.

It has a ProAct.Registry.FunctionProvider registered on the f and l namespaces.

Override this instance or register your own providers in it to extend the ProAct.js DSL.

VERSION

String static