-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
Synchronous operation #163
Comments
I find myself writing an application inside a proprietary app container that expects that frontend code (which started as a simple template, which ran synchronously) to return html string synchronously. The code now contains a bunch of
It's a queue anyway, right? Let's call ticks on the microtask queue microticks if this lessens confusion. Do you think microtask queue does not inflict overhead compared to synchronous code? |
Ok, I think we're pretty much on the same page. I don't want to add But I agree that synchronous router could be useful in some certain cases. What do you think about an add-on approach like we already have with url generation? For example something like: import UniversalRouter from 'universal-router'
import resolveSync from 'universal-router/resolveSync'
const router = new UniversalRouter(routes)
resolveSync(router, pathnameOrContext) // => result or import UniversalRouter from 'universal-router'
import withResolveSync from 'universal-router/withResolveSync'
const Router = withResolveSync(UniversalRouter)
const router = new Router(routes)
router.resolveSync(pathnameOrContext) // => result or import UniversalRouter from 'universal-router/sync'
const router = new UniversalRouter(routes)
router.resolve(pathnameOrContext) // => result |
I'm submitting a ...
Sometimes a third party api forces you to run synchronously (this was the reason I could not integrate
universal-router
into my project). Or you want to just keep it simple or avoid extra unnecessary ticks.Since consumers may already expect that
resolve
always returns a promise, this may be implemented by adding aresolveSync
method.The text was updated successfully, but these errors were encountered: