metacom
metacom copied to clipboard
Remove `window` dependency for enhanced platform compatibility
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.
https://github.com/metarhia/metacom/blob/cb501f1dbf1d5f55f2fc77281d8e14b9ffe2a822/dist/metacom.js#L10