Skip to content

Remove window dependency for enhanced platform compatibility #386

@Pom4H

Description

@Pom4H

Is your feature request related to a problem? Please describe.

The current implementation of the metacom library relies on the global object window, which is not available on some non-browser environments, such as React Native. As a result, users of these platforms face difficulties when trying to use the metacom library. This dependency on the window object makes the library less flexible and limits its potential use cases.

Describe the solution you'd like

To make the metacom library more platform-agnostic, I propose that we remove the dependency on the global object window. Instead, we can use a more universal way to access the global object, such as globalThis. This would allow the library to be used on platforms where the window object is not available, like React Native, without causing any issues or requiring additional workarounds.

Describe alternatives you've considered

An alternative solution would be to provide a separate build of the metacom library specifically designed for use with React Native or other non-browser environments. However, this approach would require maintaining two separate codebases, which could lead to inconsistencies and make it more challenging to keep both versions up to date.

Another alternative would be to add an optional configuration parameter: "online" event listener. This would require additional documentation and could be less user-friendly than a platform-agnostic approach.

window.addEventListener('online', () => {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions