Split the library to core + react hooks
Hello NoriginMedia,
We’re planning to use SolidJS for our upcoming SmartTV project and are interested in incorporating your spatial navigation library. While converting your React hooks to SolidJS isn’t too difficult, it would require cloning the entire project, which could result in missing future updates to your engine.
It would be fantastic if the core of your library could be provided as a standalone module.
Hello @grobitto!
Thanks for reaching out and apologies for the delayed response.
Regarding your question, it should already be possible to do this, since we're exposing most of the core logic used - Most of the functions should already be exported and usable outside of React or any particular framework.
There's a note around this in the documentation here: https://github.com/NoriginMedia/Norigin-Spatial-Navigation?tab=readme-ov-file#navigation-service.
As such I will close this issue, but please feel free to reopen this or create any new issues that you might find as part of achieving this.
Happy coding!
I've tried this way, but there is an @internal annotation on SpatialNavigation export, preventing it to be used outside of your module
/** @internal */
export const SpatialNavigation = new SpatialNavigationService();
Hello again ☺️
I've tried this way, but there is an @internal annotation on SpatialNavigation export, preventing it to be used outside of your module
/** @internal */ export const SpatialNavigation = new SpatialNavigationService();
The service (class) instance itself is contained, but we export most of the functions it has:
export const {
init,
setThrottle,
destroy,
setKeyMap,
setFocus,
navigateByDirection,
pause,
resume,
updateAllLayouts,
getCurrentFocusKey,
doesFocusableExist,
updateRtl
} = SpatialNavigation;
Or are there perhaps other parts of the service that you would expect or need to have exposed?
I've checked your code from useFocusable.ts, and here is the list of functions not exported from SpatialNavigation: addFocusable removeFocusable updateFocusable
@grobitto: Alright, then we'll have a discussion internally around what we can do to expose those.
Thanks for letting us know.
I think what we will do is remove the @internal flag on the Spatial Navigation instance itself, then you can use whatever you want.
We'll follow up and highlight it here in this issue, once that change has been made.
Thank you!