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

chore: refactor store to class #6249

Merged
merged 2 commits into from
Jul 19, 2019
Merged

chore: refactor store to class #6249

merged 2 commits into from
Jul 19, 2019

Conversation

runspired
Copy link
Contributor

@runspired runspired commented Jul 12, 2019

Service.extend forces us to move all properties onto the prototype in order for them to be type checked, the syntax does not allow for method overloads, and TS struggles to flow expected types through the store methods.

This PR refactors the store into a native class, giving us much improved type checking and allowing us to use method overloads.

It surfaced one issue where we expect folks to be able to overwrite adapter as a property on the store when extending; however, when using babel+typescript and a class this is transpiled with an automatic initializer to void 0 that overwrites anything set via create or extend. We worked around this by not declaring that particular property and using a (nasty) type cast in the two locations we access it. @rwjblue does not believe this issue of interop of TS + babel + legacy .extend syntax is something apps will encounter often.

This PR builds on #6246 and #6247

Copy link
Contributor

@mike-north mike-north left a comment

Choose a reason for hiding this comment

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

TS review complete.

  • I have one major action item to research class field defaults on a prototype
  • @runspired to come up with a small repro of the babel+TS issue he's running into

packages/store/addon/-private/system/references/record.ts Outdated Show resolved Hide resolved
packages/store/addon/-private/system/store.ts Outdated Show resolved Hide resolved
packages/store/addon/-private/system/store.ts Show resolved Hide resolved
packages/store/addon/-private/system/store.ts Outdated Show resolved Hide resolved
packages/store/addon/-private/system/store.ts Outdated Show resolved Hide resolved
packages/store/addon/-private/system/store.ts Outdated Show resolved Hide resolved
packages/store/addon/-private/system/store.ts Show resolved Hide resolved
packages/store/addon/-private/system/store.ts Show resolved Hide resolved
packages/store/addon/-private/system/store.ts Outdated Show resolved Hide resolved
packages/store/addon/-private/system/store.ts Outdated Show resolved Hide resolved
Copy link
Member

@igorT igorT left a comment

Choose a reason for hiding this comment

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

Pending getting the identifiers infra getting merged

packages/-ember-data/tests/helpers/store.js Show resolved Hide resolved
@mike-north
Copy link
Contributor

@types/rsvp v4.0.3 was released today. It should allow you to consume

import { Promise } from 'rsvp';

and use it as a type

@runspired runspired merged commit e356cce into master Jul 19, 2019
@delete-merged-branch delete-merged-branch bot deleted the refactor/typed-store branch July 19, 2019 09:03
runspired added a commit that referenced this pull request Jul 31, 2019
runspired added a commit that referenced this pull request Aug 1, 2019
runspired added a commit that referenced this pull request Aug 1, 2019
@HeroicEric HeroicEric mentioned this pull request Aug 13, 2019
8 tasks
HeroicEric added a commit to HeroicEric/data that referenced this pull request Aug 13, 2019
…/store

emberjs#6249 refactored `Store` to a class.
As part of this refactoring, `Store#defaultAdapter` was implemented
using the `@computed` decorator. Using the `@computed` decorator
requires Ember 3.10+.

This adds [`ember-decorators-polyfill`](https://github.com/pzuraq/ember-decorators-polyfill)
as a dependency to `@ember-data/store` to add support for Ember < 3.10.
HeroicEric added a commit to HeroicEric/data that referenced this pull request Aug 13, 2019
…/store

Extracted from emberjs#6098

emberjs#6249 refactored `Store` to a class.
As part of this refactoring, `Store#defaultAdapter` was implemented
using the `@computed` decorator. Using the `@computed` decorator
requires Ember 3.10+.

This adds [`ember-decorators-polyfill`](https://github.com/pzuraq/ember-decorators-polyfill)
as a dependency to `@ember-data/store` to add support for Ember < 3.10.
HeroicEric added a commit to HeroicEric/data that referenced this pull request Aug 14, 2019
…/store

Extracted from emberjs#6098

emberjs#6249 refactored `Store` to a class.
As part of this refactoring, `Store#defaultAdapter` was implemented
using the `@computed` decorator. Using the `@computed` decorator
requires Ember 3.10+.

This adds [`ember-decorators-polyfill`](https://github.com/pzuraq/ember-decorators-polyfill)
as a dependency to `@ember-data/store` to add support for Ember < 3.10.
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.

3 participants