Basic Boilerplate Template
  • 15 Oct 2024
  • 1 Minute to read

Basic Boilerplate Template


Article summary

A simple example of a template:

class View extends Dise.SimpleViewBase {
    async main(helper: Dise.DataHelper): Promise<void> {

        // Executed while preloading and invisible
        // Insert your preloading code here

        await this.waitForPlay();

        // We are now visible and playing
        // Insert your playout code here
    }
}

const ctrl = new Dise.TemplateController(new View());

This requires that “templateframework/framework/index.ts” is referenced either in tsconfig.json and/or with the ///<reference path=”…” /> syntax.

The key here is await this.waitForPlay()

  • All code before calling await this.waitForPlay() will be executed in the onPreload stage.
  • If an exception is thrown, it will be handled as an error and logged and reported to the CMS.
  • If anything is returned before calling this.waitForPlay(), the template will “reject”, i.e. the player will skip this and move forward to the next item in the playlist.
  • If falsy is returned after calling this.waitForPlay(), the Player will handle when to end the template.
  • If truthy is returned after calling this.waitForPlay(), the template will be ended.
  • If a string is returned after calling this.waitForPlay(), the template will be ended and a log entry written with the reason.

This makes creating a template straightforward, since most variables can simply be locals in main(). Some class member variables may be needed if support for things like onAttribute and the state needs to be accessible from multiple event handler methods is needed.

Dise.SimpleViewBase does not support template reuse.

Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.