Mochikit
Last edited April 1, 2008
More by Ian Lewis »
MochiKit.Async - manage asynchronous tasks
mochikit.com/doc/html/MochiKit/Async.html#fn-calll...

callLater(seconds, func[, args...]):

Call func(args...) after at least seconds seconds have elapsed. This is a convenience method for:

func = partial.apply(extend(null, arguments, 1));
return wait(seconds).addCallback(function (res) { return func() });

Returns a cancellable Deferred.

Availability:
Available in MochiKit 1.3.1+

MochiKit.LoggingPane - Interactive MochiKit.Logging pane
mochikit.com/doc/html/MochiKit/LoggingPane.html#fn...

createLoggingPane(inline=false):

Create or return an existing LoggingPane for this document with the given inline setting. This is preferred over using LoggingPane directly, as only one LoggingPane should be present in a given document.

Availability:
Available in MochiKit 1.3.1+
MochiKit.DOM - painless DOM manipulation API
mochikit.com/doc/html/MochiKit/DOM.html#fn-getelem...

replaceChildNodes(node[, childNode[, ...]]):

Remove all children from the given DOM element, then append any given childNodes to it (by calling appendChildNodes).

node:
A reference to the DOM element to add children to (if a string is given, getElement(node) will be used to locate the node)
childNode...:
All additional arguments, if any, will be coerced into DOM nodes that are appended as children using the DOM Coercion Rules.
returns:
The given DOM element
Availability:
Available in MochiKit 1.3.1+

addLoadEvent(func):

Note that addLoadEvent can not be used in combination with MochiKit.Signal if the onload event is connected. Once an event is connected with MochiKit.Signal, no other APIs may be used for that same event.

This will stack window.onload functions on top of each other. Each function added will be called after onload in the order that they were added.

Availability:
Available in MochiKit 1.3.1+

getElementsByTagAndClassName(tagName, className, parent=document):

Returns an array of elements in parent that match the tag name and class name provided. If parent is a string, it will be looked up with getElement.

If tagName is null or "*", all elements will be searched for the matching class.

If className is null, all elements matching the provided tag are returned.

Availability:
Available in MochiKit 1.3.1+
MochiKit.Base - functional programming and useful comparisons
mochikit.com/doc/html/MochiKit/Base.html#fn-bind

repr(obj):

Return a programmer representation for obj. See the Programmer Representation overview for more information about this function.

Availability:
Available in MochiKit 1.3.1+

partial(func, arg[, ...]):

Return a partially applied function, e.g.:

addNumbers = function (a, b) {
return a + b;
}

addOne = partial(addNumbers, 1);

assert(addOne(2) == 3);

partial is a special form of bind that does not alter the bound self (if any). It is equivalent to calling:

bind(func, undefined, arg[, ...]);

See the documentation for bind for more details about this facility.

This could be used to implement, but is NOT currying.

Availability:
Available in MochiKit 1.3.1+

bind(func, self[, arg, ...]):

Return a copy of func bound to self. This means whenever and however the returned function is called, this will always reference the given self. func may be either a function object, or a string. If it is a string, then self[func] will be used, making these two statements equivalent:

bind("method", self);
bind(self.method, self);

Calling bind(func, self) on an already bound function will return a new function that is bound to the new self! If self is undefined, then the previous self is used. If self is null, then the this object is used (which may or may not be the global object). To force binding to the global object, you should pass it explicitly.

Additional arguments, if given, will be partially applied to the function. These three expressions are equivalent and return equally efficient functions (bind and partial share the same code path):

Availability:
Available in MochiKit 1.3.1+
The content on this page is provided by a Google Notebook user, and Google assumes no responsibility for this content.