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

Fix problem with Polyfills #636

Merged
merged 10 commits into from
Apr 11, 2018
2 changes: 1 addition & 1 deletion packages/aws-amplify/src/Cache/StorageCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export default class StorageCache {
logger.warn(`Don't try to configure keyPrefix!`);
}

this.config = Object.assign({}, this.config, config);
this.config = Object.assign({}, this.config, config, config.Cache);
this.checkConfig();
return this.config;
}
Expand Down
2 changes: 2 additions & 0 deletions packages/aws-amplify/src/Cache/types/Cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ export interface CacheConfig {
defaultPriority?: number;

storage?: Storage;

Cache?: Cache;
}

export interface CacheItem {
Expand Down
37 changes: 16 additions & 21 deletions packages/aws-amplify/src/Common/Polyfills/Polyfills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,20 @@
* and limitations under the License.
*/

(<any>global).window = (<any>global).window || {
setTimeout,
clearTimeout,
WebSocket: (<any>global).WebSocket,
ArrayBuffer: (<any>global).ArrayBuffer,
addEventListener(){ },
navigator: { onLine: true }
};
(<any>global).localStorage = (<any>global).localStorage || {
store: {},
getItem(key){
if (this.store[key]) {
return this.store[key];
}
return null;
},
setItem(key, value){
this.store[key] = value;
},
removeItem(key){ delete this.store[key]; }
};

import InMemoryCache from '../../Cache/InMemoryCache';

if (!(<any>global).window) {
(<any>global).window = {
setTimeout,
clearTimeout,
WebSocket: (<any>global).WebSocket,
ArrayBuffer: (<any>global).ArrayBuffer,
addEventListener(){ },
navigator: { onLine: true }
};
}
if (!(<any>global).localStorage){
(<any>global).localStorage = InMemoryCache;
}