Skip to content
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

Add synchronous mode to @curi/core #9

Merged
merged 12 commits into from Apr 2, 2018
Merged

Add synchronous mode to @curi/core #9

merged 12 commits into from Apr 2, 2018

Conversation

pshrmn
Copy link
Owner

@pshrmn pshrmn commented Jan 8, 2018

Current Behavior

Currently response generation is asynchronous, which allows any match.initial and match.every functions to run prior to emitting a new response.

New New Behavior

When no route object has a match.initial or match.every function, the router will automatically match routes synchronously.

@pshrmn
Copy link
Owner Author

pshrmn commented Apr 1, 2018

Update

Instead of manually selecting synchronous mode, Curi will default to synchronous, but switch to async if any route has an initial or every property.

// sync
const routes = [
  { name: Home, path: '' },
  { name: Other, path: 'other' }
];

// async
const routes = [
  { name: Home, path: '' },
  {
    name: Other,
    path: 'other'
      match: {
        initial: () => Promise.resolve('some value'),
        response({ resolved }) => {...}
      }
  }
];

@pshrmn pshrmn merged commit 73d86e6 into master Apr 2, 2018
@pshrmn pshrmn deleted the sync branch April 2, 2018 15:24
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 this pull request may close these issues.

None yet

1 participant