API Reference
The API reference details the methods available in the alt-seven framework.
The API reference details the methods available in the alt-seven framework.
Modules
a7 |
The main module of the alt-seven framework. |
a7.components |
Contains components for various functionalities like models, users, and views. |
a7.components.model |
The built-in model of the alt-seven framework used by default to implement model functionality in applications. |
a7.components.User |
A generic object with no pre-set properties for holding arbitrary user-specific properties. |
a7.components.View |
The base component for all views in alt-seven applications, allowing event bindings and dynamic rendering through template literals or functions. |
Method |
Description |
getMemento() |
Returns the arbitrary properties set by the application. |
config() |
Configuration method (not described). |
getState() |
Returns a structure representing the current state of the view. |
setState( args ) |
Sets the args structure as the current state of the view. |
addChild( view ) |
Adds another view as a child of the current view. |
removeChild( view ) |
Removes a view from the stack of child views of the current view. |
clearChildren() |
Removes all child views of the current view. |
render() |
Renders the current view, returning an HTML string. |
getParent() |
Returns the parent view of the current view. |
shouldRender() |
Determines whether the current view should be rendered based on skipRender status. |
onRendered() |
Automatically called by the framework after rendering child views. |
checkRenderStatus() |
Checks if a document node exists and handles session timers or unregisters the view if not. |
a7.console |
Handles logging messages to the console. |
Method |
Description |
addMessage ( message, date, source, level ) |
Sends a message to the console with specified details. |
a7.error |
Captures runtime errors in the application. |
Method |
Description |
captureError (msg, url, lineNo, columnNo, error) |
Handles capturing and logging of runtime errors. |
a7.events |
Manages event publishing and subscribing within the application. |
Method |
Description |
publish ( topic, info ) |
Calls an event with provided information. |
subscribe( topic, listener ) |
Creates an event listener for specified topics. |
a7.log |
Logs messages at different levels in the application. |
Method |
Description |
error( message ) |
Logs an error-level message. |
fatal( message ) |
Logs a fatal-level message. |
info( message ) |
Logs an info-level message. |
trace( message ) |
Logs a trace-level message. |
warn( message ) |
Logs a warn-level message. |
a7.model |
Manages application data and instances, including views. |
Method |
Description |
init( options ) |
Initializes the model with specified options. |
destroy( key ) |
Deletes an entry from the model using a key. |
get( key ) |
Retrieves an entry from the model by key. |
set( key, value ) |
Sets or updates an entry in the model using a key and value. |
exists( key ) |
Checks if an entry exists in the model with a specific key. |
a7.remote |
Handles remote HTTP calls and WebSocket connections. |
Method |
Description |
init( modules ) |
Initializes the remote module with specified modules. |
fetch( uri, params, secure) |
Makes an HTTP request to a specified URI and returns a promise. |
invoke( moduleAction, params) |
Invokes an action in a specified module with provided parameters. |
getToken |
Retrieves the session token for the current user. |
invalidateToken |
Invalidates the session token for the current user. |
getSessionTimer |
Returns the timer object tracking the user’s session. |
webSocket( wsServer, messageHandler, isJSON ) |
Establishes a WebSocket connection with the specified server and handler function. |
auth |
Methods for handling authentication. |
Method |
Description |
login(params) |
Calls a server-side authentication endpoint. |
logout(params) |
Calls a server-side logout endpoint. |
refresh(params) |
Keeps the current user session alive by calling a specified server-side endpoint. |
a7.router |
Manages routing and navigation within applications. |
Method |
Description |
init(options) |
Initializes the router with specified options. |
open(path, params) |
Opens a specified path and publishes mapped events. |
add(path, handler) |
Maps a new route to a handler function. |
find(path) |
Retrieves a route map by path. |
match(path) |
Checks if a path is mapped in the routes. |
a7.security |
Handles security-related functionalities such as session management and authentication status checks. |
Method |
Description |
init() |
Initializes the security module. |
invalidateSession() |
Ends the current session by clearing the user object. |
isAuthenticated() |
Checks if the current user is authenticated. |
a7.ui |
Manages UI selectors, views, and event bindings. |
Property |
Description |
selectors |
Collection of document selectors set by the application. |
views |
Collection of View objects managed by the application. |
Method |
Description |
init() |
Initializes the UI module. |
getEvents() |
Retrieves all browser events handled by the UI module. |
getSelector(name) |
Returns a specified selector by name. |
setSelector(name, selector) |
Sets a new selector or updates an existing one by name. |
getNode(selector) |
Retrieves a DOM node using a selector. |
register(view) |
Registers a view in the application. |
unregister(id) |
Unregisters a view from the application. |
getView(id) |
Retrieves a view by its ID. |
enqueueForRender(id) |
Adds a view to the render queue for rendering. |
removeView(id) |
Removes a view from the application using its ID. |
a7.util |
Provides utility functions for various tasks. |
Method |
Description |
split (val) |
Splits the input string by commas into an array. |
extractLast(term) |
Retrieves the last term from a comma-separated list. |
encode64(input) |
Encodes a string using Base64 encoding. |
decode64(input) |
Decodes a Base64 encoded string. |
leadingZero(n) |
Prepends a zero to a single-digit number. |
dynamicSort( property ) |
Dynamically sorts an array of objects based on the specified property. |
yesNo( val ) |
Converts a value to “Yes” or “No”. |
isValidDate( d ) |
Checks if the input is a valid date object. |
id() |
Generates a unique ID string. |
tryCatch(fn,ctx,args) |
Attempts to execute a function and catches any errors. |
getNumberValue(value) |
Retrieves a number value from an input or returns null if invalid. |
isNumeric(num) |
Checks if the input is numeric. |
getOffset(selector) |
Retrieves the offset of a DOM element specified by a selector. |
Last modified April 28, 2024:
API reference update (1cd08f1)