Skip to content

feat(rive): stateChange event for state machine transitions #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stasdav
Copy link

@stasdav stasdav commented Jul 13, 2025

Title
Add stateChange event for RiveView (iOS + Android)

Summary
Exposes State Machine transitions from the native Rive runtimes to JS.
Works the same on both platforms.

Changes

  • common.ts – adds missing stateChangedEvent constant.
  • iOS RiveStateMachineDelegateImpl – calls owner.notify({ eventName: 'stateChange', ... }).
  • Android listener – mirrors the same call.
  • index.d.ts – declares on('stateChange', ...) for type safety.

Why
Apps need to react when a Rive State Machine enters a new state (e.g. to chain logic or UI).
Until now this info was only available inside native code.
No breaking changes; existing code keeps working.

Copy link

cla-bot bot commented Jul 13, 2025

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Stas.
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email [email protected]
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

@stasdav
Copy link
Author

stasdav commented Jul 13, 2025

I can't fully test this patch in a real app because npm doesn't support installing a single package from a monorepo subfolder via a GitHub URL. So I can't use my app's package.json to point to this fork or PR branch.

The only way is to build and pack the package locally, or ask a maintainer to publish a prerelease. If there’s a better workflow for app-level testing with monorepo packages, please let me know!

@NathanWalker NathanWalker changed the title Add cross-platform stateChange event to RiveView for State Machine transitions feat(rive): stateChange event for state machine transitions Jul 13, 2025
@NathanWalker
Copy link
Contributor

NathanWalker commented Jul 13, 2025

This is excellent @stasdav 💯 - Build/pack is a good way to confirm in a monorepo. npm start > buildrive ENTER, then cd dist/packages/rive > npm pack and just pwd to include full abs path to the .tgz in the monorepo (clean/run).

"@nativescript/rive": "file:/Users/me/path/to/ui-kit/dist/packages/rive/nativescript-rive-x.x.x.tgz"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants