Skip to content

Latest commit

 

History

History
45 lines (32 loc) · 1.77 KB

File metadata and controls

45 lines (32 loc) · 1.77 KB

PromiseRejectionEvent

Namespace: SpawnDev.SpawnJS.JSObjects
Inherits: Event
Source: JSObjects/PromiseRejectionEvent.cs
MDN Reference: PromiseRejectionEvent on MDN

The PromiseRejectionEvent interface represents events which are sent to the global script context when JavaScript Promises are rejected. These events are particularly useful for telemetry and debugging purposes. https://developer.mozilla.org/en-US/docs/Web/API/PromiseRejectionEvent

Constructors

Signature Description
PromiseRejectionEvent(SpawnJSObjectReference _ref) Deserialization constructor

Properties

Property Type Access Description
Promise Promise get The JavaScript Promise that was rejected.

Methods

Method Return Type Description
ReasonAs() T A value or Object indicating why the promise was rejected, as passed to Promise.reject().

Examples

SpawnDev.SpawnJS Mapping Note: The JavaScript examples below show the standard Web API usage. In SpawnDev.SpawnJS, the same API is available with C# conventions:

  • Properties and methods use PascalCase (e.g., readyState becomes ReadyState)
  • Events use ActionEvent with +=/-= (e.g., addEventListener("click", fn) becomes OnClick += handler)
  • Async methods return Task<T> instead of Promise<T>
  • Objects should be disposed with using statements
  • Access via JS.Get<PromiseRejectionEvent>(...) or constructor new PromiseRejectionEvent(...)
window.onunhandledrejection = (e) => {
  console.log(e.reason);
};

See full example on MDN