constructor(typeId: TypeId, assetId: AssetId, path: string)
View sourceCreates success event data for a saved asset.
Class
Event data for an asset save that completed successfully.
A AssetServer#save request produces this event after the asset is
serialized by its registered exporter and the POST request to path
receives a successful response. The event becomes readable when the typed
Events<AssetSaveSuccess> resource publishes its pending batch. Failed
saves publish AssetLoadFail instead.
The payload identifies the asset family, the packed ID from the saved handle, and the destination path. It does not include the serialized body or the response; consumers that need those values must handle them during their own save workflow.
import { AssetSaveSuccess, Assets } from '@wimaengine/asset'
import { Events } from '@wimaengine/event'
import { typeid } from '@wimaengine/type'
class Texture {}
const assets = new Assets(Texture)
const assetId = assets.add(new Texture()).id()
const typeId = typeid(Texture)
const path = '/textures/player.bin'
const events = new Events()
// The success event is available after the save response succeeds.
events.write(new AssetSaveSuccess(typeId, assetId, path))
events.clear()
events.each(({ data }) => {
console.log(`Saved ${data.path} for asset ${data.assetId}`)
})constructor(typeId: TypeId, assetId: AssetId, path: string)Creates success event data for a saved asset.
Runtime type ID of the saved asset’s constructor.
Packed asset ID from the handle that was saved.
Destination path used by the successful save request.