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

feat: Improved adapter and persister registration #62

Merged
merged 4 commits into from
Jul 12, 2018
Merged

Conversation

offirgolan
Copy link
Collaborator

@offirgolan offirgolan commented Jul 12, 2018

Adapters

import { XHRAdapter, FetchAdapter } from '@pollyjs/core';

// Register the xhr adapter so its accessible by all future polly instances
Polly.register(XHRAdapter);

polly.configure({
  adapters: ['xhr', FetchAdapter]
});

Persister

import { LocalStoragePersister, RESTPersister } from '@pollyjs/core';

// Register the local-storage persister so its accessible by all future polly instances
Polly.register(LocalStoragePersister);

polly.configure({
  persister: 'local-storage'
});

polly.configure({
  persister: RESTPersister
});

@offirgolan offirgolan requested a review from jasonmit July 12, 2018 06:23
Copy link
Contributor

@jasonmit jasonmit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just docs need to be updated to reflect the changes

if (isArray(adapterName)) {
const [name, AdapterType] = adapterName;
// Disconnect from all current adapters
this.disconnect();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there tests asserting disconnect on configure (quick grep didn't find anything)? Would be useful if there isn't.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

* @param {String} key
* @returns {Boolean}
*/
has(key) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be useful for it to take a factory also (but not necessary).

@offirgolan offirgolan merged commit 164dbac into master Jul 12, 2018
@offirgolan offirgolan deleted the registration branch July 12, 2018 20:23
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.

2 participants