<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "JavaScriptCore",
  "identifier" : "/documentation/JavaScriptCore/JSValue/init(newPromiseIn:fromExecutor:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "JavaScriptCore"
    ],
    "preciseIdentifier" : "c:objc(cs)JSValue(cm)valueWithNewPromiseInContext:fromExecutor:"
  },
  "title" : "init(newPromiseIn:fromExecutor:)"
}
-->

# init(newPromiseIn:fromExecutor:)

Creates a promise object using the specified executor callback.

```
init!(newPromiseIn context: JSContext!, fromExecutor callback: ((JSValue?, JSValue?) -> Void)!)
```

## Parameters

`context`

The [`JSContext`](/documentation/JavaScriptCore/JSContext) the resulting [`JSValue`](/documentation/JavaScriptCore/JSValue) belongs to.

`callback`

A callback block to invoke during initialization of the promise object. The `resolve` and `reject` parameters are functions that you can call to notify any pending reactions about the state of the new promise object.

## Return Value

A [`JSValue`](/documentation/JavaScriptCore/JSValue) that represents a new promise JavaScript object.

## Discussion

This method is equivalent to calling the `Promise()` constructor in JavaScript.

The `resolve` and `reject` callbacks each typically take a single value, which they forward to all relevant pending reactions. While inside the executor callback, `context` acts as if it is in any other callback, except `calleeFunction` is `nil`. This also means you can access the new promise object using `[context thisValue]`.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)