Comments (8)
You should already be able to set it to null
instead.
from hooks.
null
is not undefined
- they are not strictly equal and typescript won't even allow to assign null there.
from hooks.
The typing should be updated to allow null
then since it should be possible. undefined
is however not supported as a service return or hook result value.
from hooks.
But hooks are not only about services, aren't they?
Well if the official position is that undefined
should not be supported as a possible return value of a function - then this can be closed.
from hooks.
That's fair. One option would be to add an UNDEFINED
symbol that you can set the result to in https://github.com/feathersjs/hooks so it would be possible going forward.
from hooks.
Yeah, thought about it (symbol). But it creates problems when you work with arbitrary functions and set their result to result
property. So now you'll need to replace their undefined
with UNDEFINED
and if you access context.result
you need to remember about UNDEFINED
and so on... (and I'm sure nobody will remember)
from hooks.
It creates problems when undefined
can mean both things - actual return value and absence of a value.
In feathers ecosystem you control rules and you can ban undefined as a return value of services, solving the ambiguity.
But when it is about random functions (many of which will be void, so should return only undefined) - i don't think you can make it work without opening door for bugs...
I assume that you don't like the idea because of breaking nature, right? Or is there anything else against it?
from hooks.
You're right, this is a good suggestion and I don't think it would be a breaking change.
I just created a pull request in #70 that should allow to do what you are suggesting by checking if there is a property descriptor for context.result
. That way if context.result
is ever set to anything at all in the hook chain, the method call will be skipped.
from hooks.
Related Issues (20)
- Version 0.7.x fails to compile in Webpack HOT 3
- ERROR in ./node_modules/@feathersjs/hooks/esm/base.js 55:38 HOT 4
- Error hooks - re-throwing vs assigning context.error
- Allow to change the order of middleware HOT 2
- integrate it to existing feathers app HOT 7
- Combining multiple middleware with compose HOT 1
- API usage improvements HOT 1
- Brings webpack as dependency and many other due to that HOT 6
- Unable to add a context collector for all methods of an object HOT 1
- Performance optimizations HOT 8
- Turn .params, .props and .defaults into hooks HOT 2
- Order of multiple hooks: mismatch of documentation and behavior HOT 2
- Is it possible to remove a hook? HOT 2
- Wrong method name in context.method HOT 6
- function.length is lost HOT 4
- Deno port chores HOT 1
- Error: Could not dynamically require "./base.js". HOT 3
- Notes on regular hooks support HOT 1
- Critical dependency: require function is used in a way in which dependencies cannot be statically extracted HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hooks.