Application API
rollcake-spa exports named classes, functions and variables rather than a single default export. This means importing must happen in one of two ways:
createElement
createElement
it's a method to perform the creation of the Element class which is responsible for append DOM nodes.
Simple arguments
arguments
- tag: string
- Contain the HTML tag that will be created in DOM.
- attr: Object
- Contain in it attribute declaration what should be add as attribute with the DOM element being created, e.g.: name, class, style, id, and others.
- props: Object
- Contain props that will be inserted with the DOM element being created, e.g.: textContent, innerHTML, innerText, and eventListener.
- children: Array of Elements
- A list of elements that will be render under the current element
returns
Object
createPage
createPage
it's a method to perform the creation of the Page class which is responsible for order the render and destruction of elements, and lifecycle functions.
Simple arguments
arguments
- onInit: () => void
- Function that will be executed when the page be initialized
- onDestroy: () => void
- Function that will be executed when the page be destroyed
- onUpdate: () => void
- Function that will be executed when the shared data base of the application be updated
- content: () => Object
- Elements that will be applied to the DOM after render method be executed
returns
Object
RollCakeMFBroker
RollCakeMFBroker
class register parcels and prepare a fully shareable communication and data storage environment between them and the application. This one, can be consider this module with the most value-added artifact of the project.
Simple arguments
arguments
- Buckets: Array of Bucket
- List of buckets that should be register and intermidated by broker.
returns
Object
RollCakeRouter
RollCakeRouter
class will be responsible for making the declaration, identification and control of routes of the application.
Simple arguments
arguments
- Routes: Array of Route
- List of pages and location that could be render.
- Mode: string
- Preferred mode navigation of router.
returns
Object
RollCakeSpa
RollCakeSpa
class will be responsible for the use and integration of all previous classes, along with the ability to render,
destroy, and update on-screen elements.
Simple arguments
arguments
- MFBroker: RollCakeMFBroker
- Instance of the class responsible for register and reference the parcels.
- Router: RollCakeRouter
- Instance of the class responsible for control route preferences.
- entryDOMNode: HTMLElement
- Reference of a DOM node that will receive the elements to be render.
- loadingContent?: () => Element
- Function that will be trigger while the parcels are being fetched.
returns
Object