logologo
Get Started
Guide
Development
Plugins
API
Home
English
简体中文
日本語
한국어
Español
Português
Deutsch
Français
Русский
Italiano
Türkçe
Українська
Tiếng Việt
Bahasa Indonesia
ไทย
Polski
Nederlands
Čeština
العربية
עברית
हिन्दी
Svenska
Get Started
Guide
Development
Plugins
API
Home
logologo
RunJS Overview
Import Modules
Render in Container

Globals

window
document
navigator

ctx

ctx.blockModel
ctx.collection
ctx.collectionField
ctx.dataSource
ctx.dataSourceManager
ctx.element
ctx.exit()
ctx.exitAll()
ctx.filterManager
ctx.form
ctx.getModel()
ctx.getValue()
ctx.getVar()
ctx.i18n
ctx.importAsync()
ctx.initResource()
ctx.libs
ctx.location
ctx.logger
ctx.makeResource()
ctx.message
ctx.modal
ctx.model
ctx.notification
ctx.off()
ctx.on()
ctx.openView()
ctx.render()
ctx.request()
ctx.requireAsync()
ctx.resource
ctx.route
ctx.router
ctx.setValue()
ctx.sql
ctx.t()
ctx.view
Previous Pagectx.logger
Next Pagectx.message

#ctx.makeResource()

Create a new resource instance and return it, without modifying ctx.resource. Use when you need multiple independent resources or a temporary resource.

#Type

makeResource<T = FlowResource>(resourceType: ResourceType<T>): T;
  • resourceType: resource type, a class name string or constructor, e.g. 'MultiRecordResource', 'SingleRecordResource', 'SQLResource', 'APIResource'.
  • Return: the newly created resource instance.

#Example

// Create a list resource without changing ctx.resource
const listRes = ctx.makeResource('MultiRecordResource');
listRes.setResourceName('users');
await listRes.refresh();

// ctx.resource remains unchanged (if any)
const current = ctx.resource;

Difference from initResource: makeResource only creates a new instance; initResource initializes and binds to context when ctx.resource is missing.

See detailed APIs for each Resource type:

  • MultiRecordResource - multiple records / list
  • SingleRecordResource - single record
  • APIResource - generic API resource
  • SQLResource - SQL query resource