-
Notifications
You must be signed in to change notification settings - Fork 25
Conversation
All tests passed. The build is hanging on "Created session iphone 9.3 on any platform". It doesn't seem to be caused by my changes. |
}); | ||
} | ||
}, | ||
const createInMemoryStorage: InMemoryStorageFactory = createBaseStorage.mixin(compose({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're using mixin()
, is there a reason we're also using compose()
, or could we just pass a mixin descriptor? e.g.
{
mixin: {
createId(...)
...
},
initialize(instance, options) {
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. That's a good idea and I tried it. But it doesn't seem to work. You can find the change in this branch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does seem like a strange usage, should work with the format bradley used above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now using a mixin descriptor argument instead of a factory.
uri += '/' + ids[0]; | ||
} | ||
else { | ||
uri += '?' + state.idSerializer(ids); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably check if state.idSerializer
exists and default to making individual get requests here if it doesn't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. This makes sense to me. I will make the change here(get
) as well as in delete
uri += '/' + ids[0]; | ||
} | ||
|
||
return <Promise<any>> request(uri, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably check if state.requestSerializer
exists and default to making individual put requests here if it doesn't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is tricky. requestSerializer
is used as the object => string
serializer regardless of the type of the request. So it can't be used as an indicator of opt in custom request. I can probably add another option just for put
custom request scenario, unless you have other ideas.
} | ||
}, <T, O>(instance: Storage<T, O>, {target, | ||
createIdTarget, | ||
idSerializer = defaultIdSerializer, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The serializers used for multiple puts and multiple gets probably shouldn't be defaulted. If they are supporting non standard ways of doing things as a convenience we will probably want to make that an opt in behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I am making changes for this. For get
and delete
, I will repurpose idSerializer
as the indicator, and for put
, I will add another option, since requestSerializer
is being used in multiple scenarios.
I made the discussed changes. Will do a rebase once other PRs are landed. |
return itemArray.map(state.idFunction); | ||
} | ||
else { | ||
return itemArray.map(function(item) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return itemArray.map((item) => item.id);
const state = instanceStateMap.get(this); | ||
const itemArray = Array.isArray(items) ? <IdObject []> items : [ <IdObject> items ]; | ||
if (state.idProperty) { | ||
return itemArray.map((item) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return itemArray.map((item) => item[ state.idProperty ]);
headers: { | ||
'Accept': state.contentType | ||
} | ||
}).then(function(response) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utilise the arrow functions:
.then((response) => state.responseDeserializer(response.data.toString()));
}, | ||
|
||
'GET': { | ||
'ids can\'t be empty'() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you be a bit more descriptive with your names please. ie.
Should throw error when get called without ids
}); | ||
} | ||
}, | ||
const createInMemoryStorage: InMemoryStorageFactory = createBaseStorage.mixin(compose({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does seem like a strange usage, should work with the format bradley used above
Have only done a brief review. |
Thanks @tomdye for the review. I addressed the feedback. Regarding the |
@lzhoucs I would imagine the |
You're right @tomdye. And I wouldn't be surprised if typing issues were fixed by typing changes. As you can see from my change, I added generic typing As for |
Codecov Report
@@ Coverage Diff @@
## master #48 +/- ##
==========================================
- Coverage 100% 98.86% -1.14%
==========================================
Files 16 18 +2
Lines 1166 1322 +156
Branches 204 241 +37
==========================================
+ Hits 1166 1307 +141
- Misses 0 10 +10
- Partials 0 5 +5
Continue to review full report at Codecov.
|
This one was ready to land, but we're waiting for dojo/core#261 to land and then we'll refactor this on top of that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will likely need some refactoring when dojo/core#261 lands.
Closing in favor of #124 which has been rebased against the latest from master and works with the updated request API from |
Type: feature
Description:
Add a REST based storage that interacts with a target REST endpoint remotely. Refactored
createInMemoryStorage
Related Issue: #47 , #4
Please review this checklist before submitting your PR: