API Docs for: 0.2.0
Show:

client Class

Uses
Defined in: lib/client.js:20
Module: express-yui/lib/client

Provides a set of methods to be serialized and sent to the client side to boot the application in the browser.

Item Index

Methods

_bootstrap

(
  • method
  • args
)
private

Defined in lib/client.js:220

The internal bootstraping implementation.

Parameters:

  • method String

    The method to call on Y, either "use" or "require".

  • args Any

    Array of arguments to apply to the Y method.

ready

(
  • callback
)
public

Defined in lib/client.js:193

Boots the application, rehydrate the app state and calls back to notify the ready state of the app.

<script>{{{state}}}</script>
<script>
app.yui.ready(function (err) {
    if (err) {
        throw err;
    }
    app.yui.use('foo', 'bar', function (Y) {
        // do something!
    });
});
</script>

Parameters:

  • callback Function

    when the app is ready. If an error occurr, the error object will be passed as the first argument of the callback function.

require

() public

Defined in lib/client.js:172

Like app.yui.use() but instead delegates to YUI().require() after getting the seed ready. The callback passed to require() receives two arguments, the Y object like use(), but also imports which holds all of the exports from the required modules.

<script>{{{state}}}</script>
<script>
app.yui.require('foo', 'bar', function (Y, imports) {
    var Foo         = imports['foo'],
        namedExport = imports['bar'].baz;
});
</script>

use

() public chainable

Defined in lib/client.js:148

Attaches the seed into the head, then creates a YUI Instance and attaches modules into it. This is equivalent to YUI().use() after getting the seed ready. This method is a bootstrap implementation for the library, and the way you use this in your templates, is by doing this:

<script>{{{state}}}</script>
<script>
app.yui.use('foo', 'bar', function (Y) {
    // do something!
});
</script>

Where state defines the state of the express app, and app.yui defines the helpers that express-yui brings into the client side.