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: Fetch adapter support for context provided via adapterOptions #66

Merged
merged 1 commit into from
Jul 17, 2018

Conversation

jasonmit
Copy link
Contributor

@jasonmit jasonmit commented Jul 16, 2018

I'll update the docs also.

I can't apply the same treatment to the XHR adapter since nise doesn't enable providing a context object. I think we spoke about this already, but mentioning again.

Resolves #56

one.connectTo(FetchAdapter);

expect(function() {
two.connectTo(FetchAdapter);
Copy link
Contributor Author

@jasonmit jasonmit Jul 16, 2018

Choose a reason for hiding this comment

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

connectTo vs providing the adapter via configure so that the constructor assignment happens and we can do cleanup (i.e., stop())

@jasonmit jasonmit requested a review from offirgolan July 16, 2018 08:54
@jasonmit jasonmit force-pushed the u/jasonmit/fetch-context branch 2 times, most recently from 89d9c8c to 0da3667 Compare July 16, 2018 09:11
this.assert('Fetch global not found.', nativeFetch);
const { context } = this.options;

this.assert('Fetch global not found.', context.fetch);
Copy link
Collaborator

Choose a reason for hiding this comment

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

!!(context && context.fetch)

Assert only checks for false or undefined. Might wanna open that up to any falsey value.

this.handleRequest({
url,
method: options.method || 'GET',
headers: FetchUtils.serializeHeaders(options.headers),
body: options.body,
requestArguments: [url, options]
});

defineProperty(context.fetch, STUB_META, { value: {} });
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why a meta object vs a Boolean?

@@ -21,3 +21,36 @@ describe('Integration | Fetch Adapter', function() {
adapterTests();
adapterBrowserTests();
});

describe('Integration | Fetch Adapter | Concurrency', function() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you also add a test against a null context and one without fetch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup need to add tests in general around context. Will finish up tonight + docs

@offirgolan
Copy link
Collaborator

I can't apply the same treatment to the XHR adapter

I just meant the logic around checking the STUB_META instead of checking against the captured native class in the module. That way, we can still wrap a pre modified XHR.

@jasonmit
Copy link
Contributor Author

jasonmit commented Jul 17, 2018

I just meant the logic around checking the STUB_META instead of checking against the captured native class in the module. That way, we can still wrap a pre modified XHR.

I'll tackle in a separate PR tomorrow since I want to chat first.

@jasonmit jasonmit force-pushed the u/jasonmit/fetch-context branch 2 times, most recently from 83677b4 to 05dbcc0 Compare July 17, 2018 08:15
@jasonmit jasonmit merged commit 82ebd09 into master Jul 17, 2018
@jasonmit jasonmit deleted the u/jasonmit/fetch-context branch July 17, 2018 08:16
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