Sift View
presentView (value)
Called by the framework with the result of the loadView()
callback in the SiftController.
Parameters:
value
: thedata
object returned by theloadView()
callback together with the current size class and type of the Sift view.
{
"sizeClass": {
"current": {
"width": 230 | 480 | null,
"height": 230 | 520 | null
}
},
"type": "email-thread" | "summary",
"data": {} | Promise
}
Notes on field values
null
for width or height is equivalent to full screen mode, essentially taking up all the available spacedata
can contain one of the following: number, string, array, object or a Promise that will eventually return one of the previous values
willPresentView (value)
Called when a sift starts to transition between size classes.
Parameters:
value
: previous and current size classes, Sift view type and where is the Sift runningcrx
for our Chrome extension orcloud
for the Red Sift cloud.
{
"client": "crx" | "cloud",
"type": "email-thread" | "summary",
"sizeClass": {
"previous": { "width": 230 | 480 | null, "height": 230 | 520 | null },
"current": { "width": 230 | 480 | null, "height": 230 | 520 | null },
}
}
this.controller.subscribe (name, handler)
Accessible in the controller
namespace, allows the view to register for controller events.
Parameters:
name
: string, the name of the event.handler
: function, event handler function.
constructor() {
// ...
// Listens for 'count' events from the Controller
this.controller.subscribe('counts', this.onCounts.bind(this));
}
onCounts(data) {
console.log('How many did we count: ', data);
}
this.publish (name, value)
Notifies listeners for a particular event name.
Parameters:
name
: string, the name of the event.value
: object or string, the object or string to send to the listeners.
// Example usage
this.publish('submit-button', {name: 'Jim Bailey', email: '[email protected]'});
this.controller.unsubscribe (name, handler)
Removes an event listener.
Parameters:
name
: string, the name of the event.handler
: function, event handler function.
// Example usage
this.controller.unsubscribe('counts', this.onCounts.bind(this));
Handlers and this
Do not forget to bind your handlers to
this
to pass them the correct context and have access to all the methods.
Updated less than a minute ago