Interface DurandalSystemModule

Index

Properties

Methods

Properties

public noop: Function

A noop function.

public version: string

Durandal's version.

Methods

public acquire(moduleId: string): JQueryPromise

Uses require.js to obtain a module. This function returns a promise which resolves with the module instance.

Parameters

  • moduleId: string

    The id of the module to load.

Returns

JQueryPromise

A promise for the loaded module.

public acquire(modules: Array<string>): JQueryPromise

Uses require.js to obtain an array of modules. This function returns a promise which resolves with the modules instances in an array.

Parameters

  • modules: Array<string>

Returns

JQueryPromise

A promise for the loaded module.

public acquire(moduleIds?: Array<string>): JQueryPromise

Uses require.js to obtain multiple modules. This function returns a promise which resolves with the module instances in an array.

Parameters

  • moduleIds?: Array<string> optional

Returns

JQueryPromise

A promise for the loaded module.

public assert(condition: boolean, message: string)

Asserts a condition by throwing an error if the condition fails.

Parameters

  • condition: boolean

    The condition to check.

  • message: string

    The message to report in the error if the condition check fails.

public debug(enable?: boolean): boolean

Gets/Sets whether or not Durandal is in debug mode.

Parameters

  • enable?: boolean optional

Returns

boolean

Whether or not Durandal is current debugging.

public defer(action?: (dfd: JQueryDeferred<T>) => void): JQueryDeferred

Creates a deferred object which can be used to create a promise. Optionally pass a function action to perform which will be passed an object used in resolving the promise.

Parameters

  • action?: (dfd: JQueryDeferred<T>) => void optional

Returns

JQueryDeferred

The deferred object.

public error(error: string)

Logs an error.

Parameters

  • error: string

public error(error: Error)

Logs an error.

Parameters

  • error: Error

public extend(obj: any, extensions?: Array<any>): any

Extends the first object with the properties of the following objects.

Parameters

  • obj: any

    The target object to extend.

  • extensions?: Array<any> optional

Returns

any

public getModuleId(obj: any): string

Gets the module id for the specified object.

Parameters

  • obj: any

    The object whose module id you wish to determine.

Returns

string

The module id.

public guid(): string

Creates a simple V4 UUID. This should not be used as a PK in your database. It can be used to generate internal, unique ids. For a more robust solution see node-uuid.

Returns

string

The guid.

public isArguments(obj: any): boolean

Determines if the specified object is a function arguments object.

Parameters

  • obj: any

Returns

boolean

True if matches the type, false otherwise.

public isArray(obj: any): boolean

Determines if the specified object is an array.

Parameters

  • obj: any

Returns

boolean

True if matches the type, false otherwise.

public isBoolean(obj: any): boolean

Determines if the specified object is a boolean.

Parameters

  • obj: any

Returns

boolean

True if matches the type, false otherwise.

public isDate(obj: any): boolean

Determines if the specified object is a date.

Parameters

  • obj: any

Returns

boolean

True if matches the type, false otherwise.

public isElement(obj: any): boolean

Determines if the specified object is an html element.

Parameters

  • obj: any

Returns

boolean

True if matches the type, false otherwise.

public isFunction(obj: any): boolean

Determines if the specified object is a function.

Parameters

  • obj: any

Returns

boolean

True if matches the type, false otherwise.

public isNumber(obj: any): boolean

Determines if the specified object is a number.

Parameters

  • obj: any

Returns

boolean

True if matches the type, false otherwise.

public isObject(obj: any): boolean

Determines if the specified object is a boolean.

Parameters

  • obj: any

Returns

boolean

True if matches the type, false otherwise.

public isPromise(obj: any): boolean

Determines if the specified object is a promise.

Parameters

  • obj: any

Returns

boolean

True if matches the type, false otherwise.

public isString(obj: any): boolean

Determines if the specified object is a string.

Parameters

  • obj: any

Returns

boolean

True if matches the type, false otherwise.

public keys(obj: any): Array<string>

Gets all the owned keys of the specified object.

Parameters

  • obj: any

Returns

Array<string>

The keys.

public log(msgs?: Array<any>)

Logs data to the console. Pass any number of parameters to be logged. Log output is not processed if the framework is not running in debug mode.

Parameters

  • msgs?: Array<any> optional

public resolveObject(module: any): any

Resolves the default object instance for a module. If the module is an object, the module is returned. If the module is a function, that function is called with new and it's result is returned.

Parameters

  • module: any

    The module to use to get/create the default object for.

Returns

any

The default object for the module.

public setModuleId(obj: any, id: string)

Sets the module id for the specified object.

Parameters

  • obj: any

    The object whose module id you wish to set.

  • id: string

    The id to set for the specified object.

public wait(milliseconds: number): JQueryPromise

Uses a setTimeout to wait the specified milliseconds.

Parameters

  • milliseconds: number

    The number of milliseconds to wait.

Returns

JQueryPromise