Skip to content

Refactor PlayroomKit  #40

@momintlh

Description

@momintlh

This isn't a feature/bug issue but rather an issue for refactoring/cleaning the SDK. As we are using callbacks in many parts of the C# wrapper, it is getting quite messy, we have the following pattern in multiple parts:

private static Action SomeCallback = null;

[DllImport("__Internal")]
private static extern void InternalJSLIBFunction(Action callback)

// Callback Invoker
[MonoPInvokeCallback(typeof(Action))]
private static void CallBackInvoker()
{
    SomeCallback?.Invoke();
}

// Exposed Function
public static void ExposedFunction(Action callback) 
{
SomeCallback = callback;
InternalJSLIBFunction(CallBackInvoker);
}

And to use the function we usually do something like this:

PlayroomKit.ExposedFunction(() = > {
   // Do Something when callback is invoked
})

or

PlayroomKit.ExposedFunction(callback);
void callback() 
{
// Do Something when callback is invoked
}

What we can do is to make a custom class for handling callbacks this will simplify the current codebase and make it easier for future updates/fixes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions