Skip to content

feat: remove addEventListener API#119

Draft
kieran-osgood-shopify wants to merge 3 commits into
mainfrom
kieran-osgood/05-14-featremoveaddeventlistenerapi
Draft

feat: remove addEventListener API#119
kieran-osgood-shopify wants to merge 3 commits into
mainfrom
kieran-osgood/05-14-featremoveaddeventlistenerapi

Conversation

@kieran-osgood-shopify
Copy link
Copy Markdown
Contributor

@kieran-osgood-shopify kieran-osgood-shopify commented May 14, 2026

What changes are you making?

The current React Native API exposes checkout.addEventListener(event, callback) for close, error, and geolocationRequest.

It operates on a "global" singleton pattern, and works well for responding to things like AppState or Keyboard, but not so much on the instances of AcceleratedCheckoutButtons or the ShopifyCheckout component.

Removing it in this PR leads us towards the future state API in upstack PR's

  <CheckoutSheet
        url={checkoutUrl}
        onCancel={() => setVisible(false)}
        onFail={() => {}}
        protocol={{
          start:    chk => analytics.track('checkout_start', { id: chk.id }),
          complete: chk => {
            reset();
            setVisible(false);
          },
          error:    err => toast(err.messages[0]?.content ?? 'Checkout error'),
        }}
      />


 ShopifyCheckoutKit.present(url, sdkHandlers, { [CheckoutProtocol.start]: c => {c.checkourUrl} })

How to test


Before you merge

Important

  • I've added tests to support my implementation
  • I have read and agree with the Contribution Guidelines
  • I have read and agree with the Code of Conduct
  • I've updated the relevant platform README (platforms/swift/README.md and/or platforms/android/README.md)

Releasing a new Swift version?
  • I have bumped the version in ShopifyCheckoutKit.podspec
  • I have bumped the version in platforms/swift/Sources/ShopifyCheckoutKit/ShopifyCheckoutKit.swift
  • I have updated platforms/swift/CHANGELOG.md
  • I have updated the SwiftPM/CocoaPods version snippets in platforms/swift/README.md (major version only)
Releasing a new Android version?
  • I have bumped the versionName in platforms/android/lib/build.gradle
  • I have updated platforms/android/CHANGELOG.md
  • I have updated the Gradle/Maven version snippets in platforms/android/README.md

Tip

See the Contributing documentation for the full release process per platform.

Copy link
Copy Markdown
Contributor Author

kieran-osgood-shopify commented May 14, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 14, 2026

React Native — Coverage Report

Lines Statements Branches Functions
Coverage: 99%
97.26% (249/256) 90.5% (143/158) 100% (67/67)

@kieran-osgood-shopify kieran-osgood-shopify force-pushed the kieran-osgood/05-14-featremoveaddeventlistenerapi branch from fe4bbe0 to 866347c Compare May 14, 2026 22:05
* released.
*/
present(checkoutURL: string): void;
present(checkoutURL: string, callbacks?: PresentCallbacks): void;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

terminology to be aligned with native implementations - previously "CheckoutDelegate" or "CheckoutEventProcessor"

@tiagocandido tiagocandido added the #gsd:50662 Rebase Checkout Kit on UCP label May 15, 2026 — with Graphite App
@kieran-osgood-shopify kieran-osgood-shopify changed the base branch from kieran-osgood/05-14-featremovecheckoutlifecyclefromreact-native to graphite-base/119 May 15, 2026 16:58
@kieran-osgood-shopify kieran-osgood-shopify changed the base branch from graphite-base/119 to kieran-osgood/05-14-featreact-nativeuselocalandroid/swiftprojectreferences May 15, 2026 16:58
@kieran-osgood-shopify kieran-osgood-shopify force-pushed the kieran-osgood/05-14-featreact-nativeuselocalandroid/swiftprojectreferences branch from ca7804f to 27e1a45 Compare May 15, 2026 17:57
@kieran-osgood-shopify kieran-osgood-shopify force-pushed the kieran-osgood/05-14-featremoveaddeventlistenerapi branch from 866347c to 86cefb5 Compare May 15, 2026 17:57
@kieran-osgood-shopify kieran-osgood-shopify changed the base branch from kieran-osgood/05-14-featreact-nativeuselocalandroid/swiftprojectreferences to graphite-base/119 May 15, 2026 18:12
@kieran-osgood-shopify kieran-osgood-shopify force-pushed the kieran-osgood/05-14-featremoveaddeventlistenerapi branch from 86cefb5 to fc3c557 Compare May 15, 2026 18:14
@graphite-app graphite-app Bot changed the base branch from graphite-base/119 to main May 15, 2026 18:14
@kieran-osgood-shopify kieran-osgood-shopify force-pushed the kieran-osgood/05-14-featremoveaddeventlistenerapi branch from fc3c557 to 3fe052f Compare May 15, 2026 18:14
@kieran-osgood-shopify kieran-osgood-shopify marked this pull request as ready for review May 19, 2026 14:14
@kieran-osgood-shopify kieran-osgood-shopify requested a review from a team as a code owner May 19, 2026 14:14
@kieran-osgood-shopify kieran-osgood-shopify marked this pull request as draft May 19, 2026 14:14
@kieran-osgood-shopify kieran-osgood-shopify force-pushed the kieran-osgood/05-14-featremoveaddeventlistenerapi branch 2 times, most recently from be2d4ac to 054ed77 Compare May 19, 2026 18:53
@kieran-osgood-shopify kieran-osgood-shopify marked this pull request as ready for review May 20, 2026 08:35
@kieran-osgood-shopify kieran-osgood-shopify marked this pull request as draft May 20, 2026 08:35
@kieran-osgood-shopify kieran-osgood-shopify force-pushed the kieran-osgood/05-14-featremoveaddeventlistenerapi branch from 538a16b to 0967be1 Compare May 20, 2026 10:44
@kieran-osgood-shopify kieran-osgood-shopify force-pushed the kieran-osgood/05-14-featremoveaddeventlistenerapi branch 2 times, most recently from ef1aa23 to 4cf6e67 Compare May 20, 2026 12:04
…nd loud unknown-type warning

- Centralise SDK lifecycle event names in a single source of truth per
  language: src/dispatch-events.ts (TS), DispatchEventTypes (Java),
  DispatchEventType enum (Swift). Native emits envelopes using these
  constants instead of free string literals.
- Expose the native list via getConstants(); JS verifies set-equality
  in the ShopifyCheckout constructor and throws DispatchEventParityError
  with a 'rebuild native code' message on mismatch (memoised per process).
- Per-case payload validation in the dispatcher: malformed 'fail' or
  'geolocationRequest' payloads now log a LifecycleEventParseError
  instead of feeding undefined into user code.
- Unknown envelope types now console.warn instead of silently routing
  to a missing handler, surfacing native/JS contract drift that slips
  past the parity check.
- Drop dead code: sendEventWithStringData, unused Context param and
  reactContext field on CustomCheckoutListener; unused mockContext in
  the Android test.
- Log warning instead of silent return when a multi-shot geolocation
  prompt arrives after the dispatcher has been released by a terminal
  event.
@kieran-osgood-shopify kieran-osgood-shopify force-pushed the kieran-osgood/05-14-featremoveaddeventlistenerapi branch from 4cf6e67 to bb2ece5 Compare May 20, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

#gsd:50662 Rebase Checkout Kit on UCP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants