-
Notifications
You must be signed in to change notification settings - Fork 268
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
Feature Proposal: withoutErrors() #138
Comments
I rewrote your given code so I could understand it better. I'm still confused at what "return MyModel.fromAPI(apiModel)" is conceptually doing - would you mind explaining a little deeper? I think I get the overall problem you're trying to solve, but I was trying to think of a temporary workaround (assuming you haven't found one already) and it's easier to find a workaround given a concrete example. edit: nvm - give me another moment. I realize I initially read the pseudo-code incorrectly. |
The below code is what you're after correct? I'm not a maintainer but personally I've been adding extensions to a separate file (e.g. lazy-extensions.js) then requiring that file instead. This would at least enable you to use this functionality everywhere without having to write the below function each time.
|
Effectively, yes. It's not hard to write, but it adds clutter that makes it harder to understand what's going on in the non-error case. It would be awesome if there was something like I could certainly have my own version of |
Agreed - I also think it would be cool to pass in an array of error types which you deem as 'okay' to keep iterating, and if other unexpected errors happen to escape iteration per-normal. From the javascript source code I come across though - specific error types are a rarity x.x |
I'd be cool with that. |
Let me think about this. I'm certainly not opposed to the idea, but I'm not 100% sure I want to include it in "core" Lazy.js either. The truth is I've been thinking about slimming Lazy down and relegating some of its functionality to some sort of extension, and then putting some love into the library's extensibility in general. @olsonpm: I'd love to chat with you about how you've been extending the library for your own purposes, and maybe bounce some ideas off of you about what the API for customizing and making your own helpers and sequence types would look like. Is that something you'd be interested in? |
For sure. And the hard part would definitely be defining what belongs in the core library, what belongs in a 'core' extension, and what you should leave people to write on their own. |
Consider this code:
I don't know that what I get back from the API will always be sane, but I don't want to throw away 99 good models because 1 is invalid. Especially for prototypes and demos, it would be great if I could add
withoutErrors
to the chain, which would try to map each model, catch errors, and compact them away. Hence, if I had 99 good passes and 1 bad, I'd get back an array of 99 elements (and aconsole.error
call explaining the missing one).The text was updated successfully, but these errors were encountered: