Skip to content

Commit

Permalink
Merge pull request #675 from tchak/add-more-deprecations
Browse files Browse the repository at this point in the history
Add more deprecations
  • Loading branch information
dgeb authored Jul 10, 2019
2 parents 1891847 + bbcd622 commit 46e0f55
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/@orbit/indexeddb/src/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import Orbit, {
import { supportsIndexedDB } from './lib/indexeddb';
import IndexedDBCache, { IndexedDBCacheSettings } from './cache';

const { assert } = Orbit;
const { assert, deprecate } = Orbit;

export interface IndexedDBSourceSettings extends SourceSettings {
namespace?: string;
Expand Down Expand Up @@ -86,6 +86,11 @@ export default class IndexedDBSource extends Source
await this._cache.reopenDB();
}

closeDB() {
deprecate('`closeDB()` must be called as `cache.closeDB()`.');
return this.cache.closeDB();
}

/////////////////////////////////////////////////////////////////////////////
// Resettable interface implementation
/////////////////////////////////////////////////////////////////////////////
Expand Down
14 changes: 14 additions & 0 deletions packages/@orbit/memory/src/memory-cache.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable valid-jsdoc */
import Orbit from '@orbit/core';
import { clone, Dict } from '@orbit/utils';
import { Record, RecordIdentity, equalRecordIdentities } from '@orbit/data';
import {
Expand All @@ -8,6 +9,8 @@ import {
} from '@orbit/record-cache';
import { ImmutableMap } from '@orbit/immutable';

const { deprecate } = Orbit;

export interface MemoryCacheSettings extends SyncRecordCacheSettings {
base?: MemoryCache;
}
Expand All @@ -34,6 +37,17 @@ export default class MemoryCache extends SyncRecordCache {
return this._records[identity.type].get(identity.id);
}

records(type: string) {
deprecate(
'`records(type).get(id)` is deprecated, use `getRecordSync(identity)`.'
);
return {
get: (id: string) => {
return this.getRecordSync({ type, id });
}
};
}

getRecordsSync(typeOrIdentities?: string | RecordIdentity[]): Record[] {
if (Array.isArray(typeOrIdentities)) {
const records: Record[] = [];
Expand Down

0 comments on commit 46e0f55

Please sign in to comment.