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

Allow users to override/replace/add resolvers and parsers #8

Closed

Conversation

xaka
Copy link

@xaka xaka commented Jan 5, 2016

No description provided.

@JamesMessinger
Copy link
Member

Great minds think alike! I'm literally working on implementing this right now. Instead of just two options (one for files and one for urls), you'll have the ability to define any number of arbitrary resolvers. This will allow people to support any protocol they need, such as ftp://, mongodb://, etc.

Hopefully I'll finish this tonight.

@xaka
Copy link
Author

xaka commented Jan 6, 2016

That's great! Please keep door open for substituting our own generic resolver regardless of protocol. In my case I have a virtual filesystem within browser and I wanted to be able to resolve referenced documents from there.

@JamesMessinger
Copy link
Member

👍 That should be totally possible. I'm allowing you to completely override and/or disable any of the built-in resolvers, so you can completely disable the default functionality and substitute your own if you want.

@JamesMessinger
Copy link
Member

Once I get the code committed, I'd love your feedback. I want to make sure it's flexible enough for a variety of different use-cases.

@xaka
Copy link
Author

xaka commented Jan 6, 2016

Sure thing! You can open PR when you're done and I'd take a look at proposed changes with pleasure. Let's close this one.

@xaka xaka closed this Jan 6, 2016
@xaka
Copy link
Author

xaka commented Jan 6, 2016

I've just got one important thought. With overridable resolvers there has to be an option to disable caching entirely otherwise resolvers are going to work with unexpected side effects (and usually have their own caching strategies).

@JamesMessinger
Copy link
Member

Yeah, each resolver will have its own cache duration, just like the options.cache.xxx that exists today. There will be default cache durations, but they can be changed by the user. And any cache duration can be set to zero to disable caching altogether for that resolver. Does that meet your needs?

@xaka
Copy link
Author

xaka commented Jan 6, 2016

👍

@JamesMessinger
Copy link
Member

@xaka - I've check-in my changes (didn't bother doing a new PR). It's not fully tested yet, so I haven't released it to NPM or anything, and I haven't updated the docs yet. But feel free to take a look and give your feedback on what's there.

I'm calling it a night. Will pick it back up tomorrow.

@xaka
Copy link
Author

xaka commented Jan 6, 2016

I took a look and I think the change is reasonable, and gives enough flexibility to override the default behavior. I'm looking forward for next release in order to jump off my fork as I really need that "overridable resolvers" feature.

@JamesMessinger JamesMessinger changed the title Added new $refs.* options to override implementation of internal reader Allow users to override/replace/add resolvers and parsers Jan 8, 2016
JamesMessinger added a commit that referenced this pull request Jan 8, 2016
Not quite done yet, but REALLY close
@xaka xaka force-pushed the features/override-internal-reader branch from 9693797 to 820c0b9 Compare January 11, 2016 17:14
JamesMessinger added a commit that referenced this pull request Jan 12, 2016
Finished all code changes and tests.  Still need to update docs
@malko
Copy link

malko commented Feb 3, 2016

🆙

@Nautigsam
Copy link

🆙 I would love to see this implemented :)

@JamesMessinger
Copy link
Member

Done! This just landed in v3.0.0

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.

4 participants