Code Monkey home page Code Monkey logo

Comments (2)

ethanresnick avatar ethanresnick commented on June 25, 2024

Hey Andrew,

At any rate, I think these transforms could detect whether a Promise is being returned, and wait for it to settle if needed.

I 100% agree with this and would welcome a PR.

A related thought that I’ve been thinking for some time is that maybe it would be worth exploring making each of these steps a distinct middleware. Although, that would be a function signature specific to Connect and Express servers, so maybe that doesn’t jive with the project’s vision.

There's definitely a way to do this without binding us to connect's signature, but I'm not sure I understand the value. I guess it would let the user skip the remaining transforms and respond with a success message earlier. Is there a use case for that? (Note: the user can already skip the remaining steps and jump straight to responding by throwing an error in a transform—or, when we implement your suggestion above, by returning a promise that gets rejected.)

from json-api.

andrewbranch avatar andrewbranch commented on June 25, 2024

I guess it would let the user skip the remaining transforms and respond with a success message earlier.

Yeah, and moreover, it would remove the need for named hooks like beforeSave altogether, because the implementer could insert steps at any position in the chain and decide whether to call next or to send a response. (Either of which can be done in an async callback—only reason it came to mind.) But this is much more hand-waving than is currently necessary to land this feature.

Can you give some guidance on where to add tests for this? Maybe in the create-resource integration tests?

from json-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.