npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

com.phantomsxr.actionnotification

v2.0.5

Published

The action notification manager is a function in the XRMOD framework, which is used to provide messages and Actions execution in all modules. Corresponding modules will not depend on each other, only need to issue the corresponding Action-ID to execute.

Readme

XRMODActionNotifier

The XRMODActionNotifier is a robust, lightweight, and thread-safe notification system designed for Unity and the XRMOD ecosystem. It follows the observer pattern, allowing components to communicate without direct dependencies.

Key Features

  • Flexible Observers: Register actions or functions that return results.
  • Sync & Async Support: Seamlessly handle both immediate and long-running tasks.
  • Result Collection: Collect results from multiple observers in a single notification post.
  • Reentrancy Safe: Safe to add or remove observers while a notification is being posted.

Quick Start

1. Define Notification Data

Inherit from BaseNotificationData to pass custom data.

public class UserUpdateData : BaseNotificationData
{
    public string UserName;
}

2. Register an Observer

Use ActionNotificationCenter.DefaultCenter to start listening for events.

ActionNotificationCenter.DefaultCenter.AddObserver(data => 
{
    var userData = data as UserUpdateData;
    Debug.Log($"User updated: {userData.UserName}");
}, "OnUserUpdated");

3. Post a Notification

Trigger all observers listening to the event.

ActionNotificationCenter.DefaultCenter.PostNotification("OnUserUpdated", new UserUpdateData { UserName = "JohnDoe" });

Detailed API Examples

Synchronous Notifications with Results

You can collect data back from your observers.

// Observer returning a value
ActionNotificationCenter.DefaultCenter.AddObserver(data => 
{
    return "Handled by Receiver A";
}, "GetStatus");

// Posting and collecting results
List<object> results = ActionNotificationCenter.DefaultCenter.PostNotificationWithResult("GetStatus", new BaseNotificationData());

foreach (var res in results)
{
    Debug.Log(res.ToString());
}

Asynchronous Notifications

Ideal for operations that require waiting (e.g., downloading assets, database calls).

// Register an async observer
ActionNotificationCenter.DefaultCenter.AddAsyncObserver(async data => 
{
    await Task.Delay(1000);
    return "Async task finished";
}, "DownloadStarted");

// Post and await
var results = await ActionNotificationCenter.DefaultCenter.PostNotificationAsync("DownloadStarted", new BaseNotificationData());

Important Considerations & Pitfalls

⚠️ Registration & Cleanup

Always balance your AddObserver with RemoveObserver. Failing to do so can lead to memory leaks and unexpected behavior, especially in Unity when objects are destroyed.

[!IMPORTANT] Use OnEnable for registration and OnDisable for unregistration in MonoBehaviours.

void OnDisable()
{
    ActionNotificationCenter.DefaultCenter.RemoveObserver("OnUserUpdated");
}

⚠️ Reentrancy

The system handles adding/removing observers during a PostNotification call by queuing the operations. They will be applied before the next notification is processed.

⚠️ Casting Notification Data

Since BaseNotificationData is used universally, always use safe casting (as or pattern matching) to avoid InvalidCastException.


Architecture

graph TD
    Sender[Notification Sender] -- PostNotification --> Center[ActionNotificationCenter]
    Center -- Invoke --> SYNC[SyncNotificationHandler]
    Center -- InvokeAsync --> ASYNC[AsyncNotificationHandler]
    SYNC -- Execute --> Observer1[Synchronous Observer]
    ASYNC -- Await --> Observer2[Asynchronous Observer]
    Observer1 -- Result --> Center
    Observer2 -- Task Result --> Center

Author

Developed with ❤️ by the PhantomsXR Team. Contact [email protected] for inquiries.