Skip to content

Docs for reactpy-router configuration #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Archmonger opened this issue Sep 2, 2022 · 3 comments · Fixed by #17
Closed

Docs for reactpy-router configuration #1

Archmonger opened this issue Sep 2, 2022 · 3 comments · Fixed by #17

Comments

@Archmonger
Copy link
Contributor

Currently, the readme doesn't mention how to set this up.

I see there is a bind function, but there's no usage information.

We need to put some quick documentation into the readme on usage of idom-router.

@Archmonger
Copy link
Contributor Author

@rmorshea I still have no idea how to integrate this with Django IDOM

@rmorshea
Copy link
Contributor

The general usage is:

from idom import component
from idom.backend import fastapi
from idom_router import bind, Route

Router = bind(fastapi)

@component
def example():
    return Router(
        Route(".*', some_other_component()),
        ...
    )

The type annotation indicates that bind is expecting a BackendImplementation, but technically, the only thing that's required right now is an object that has a use_location hook attached to it. So you should be able to do:

from django_idom import hooks

Router = bind(hooks)

...

To make bind more general we should do one of the following:

  1. make bind() accept a use_location hook.
  2. make bind() accept a more general object that has a use_location attribute.

I like option 2 just because I think the syntax of:

from idom.backend import fastapi

Router = bind(fastapi)

Likewise, I think it also works nicely for Django:

from django_idom import hooks

Router = bind(hooks)

@Archmonger
Copy link
Contributor Author

Archmonger commented Sep 14, 2022

If the only thing we need is use_location, we could also directly pass in the function to be more explicit.

If we need the parent module, we can manually fetch it via importlib and use_location.__module__.

Then this function potentially gets renamed to idom_router.configure, which makes things look uniform between idom core and idom-router

@rmorshea rmorshea changed the title Docs for idom-router configuration Docs for reactpy-router configuration May 11, 2023
@rmorshea rmorshea mentioned this issue May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants