client Class
Provides a set of methods to be serialized and sent to the client side to boot the application in the browser.
Item Index
Methods
Methods
_bootstrap
-
method
-
args
The internal bootstraping implementation.
Parameters:
-
method
StringThe method to call on
Y
, either"use"
or"require"
. -
args
AnyArray of
arguments
to apply to theY
method
.
ready
-
callback
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
Functionwhen the app is ready. If an error occurr, the error object will be passed as the first argument of the callback function.
require
()
public
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
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.