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

Backend-for-Montage support #1979

Open
wants to merge 48 commits into
base: master
Choose a base branch
from
Open

Backend-for-Montage support #1979

wants to merge 48 commits into from

Conversation

tejaede
Copy link
Collaborator

@tejaede tejaede commented May 14, 2018

Refactor and build out Montage Data to enable "Sentinel" project.

This branch is the consolidation of the following branches:
https://github.com/montagejs/montage/tree/features/raw-data-worker
https://github.com/montagejs/montage/tree/tej/features/data-service-mapping
https://github.com/marchant/montage/tree/data-operation-evolution

This PR encapsulates the following functionality:

  1. RawDataWorker Receives DataOperation objects and lazily initializes RawDataServices designed to handle those DataOperations.

  2. DataService Mapping Move responsibility for mapping of raw data to cooked objects and vice versa into DataService. This allows a single DataService to handle all of the data for an application without maintaining the full RawDataService tree. It follows that RawDataServices (and the responsibility to fetch data from the origin) can move off the client.

  3. DataOperation refactor Build out DataOperation API to normalize the way data travels up and down the stack.

marchant and others added 30 commits April 12, 2018 17:49
- adds a convenience method to get a DataService instance from the module
DataService organized into the following
- Snapshotting
- Service Hierarchy
- Mappings
- Model
- Data Triggers
- Data Object Properties
- Data Object Creation
- Data Object Changes
- Fetching Data
- Saving Data
- Offline
- Utilities
# Conflicts:
#	data/service/data-service.js
#	data/service/raw-data-service.js
#	test/all.js
@tejaede tejaede self-assigned this May 14, 2018
@tejaede tejaede requested review from hthetiot and marchant May 14, 2018 22:54
@hthetiot
Copy link
Contributor

Karma test with

'%cUnhandled rejection TypeError: Cannot read property 'values' of undefined

@tejaede
Copy link
Collaborator Author

tejaede commented May 21, 2018

@marchant

The values in DataOperation.Type aren't distinguishable after serialization. At the moment, it is possible to narrow them down by their CRUD action using isRead, isCreate etc, but it is not possible to distinguish a Read from a ReadCompleted from a ReadFailed. In order for it to be possible, the class needs another property in addition to (or in place of) the is flags. For example, an id property that allowed for something like operationA.type.id === operationB.type.id

Further, in order for them to be identifiable with equality in memory, it would need to be a proper class instead of a POJO. Then the check is as simple as operationA.type === operationB.type. This is the best option for efficiencies sake. With the number of operations we will be processing at each level, only 20 operation type objects floating around is a great improvement from potentially thousands of POJOs.

UPDATE
Initial implementation of DataOperationType module is here: b30aa5f

Each OperationType is added to the exports for data/service/data-operation and can be referenced as a singleton with the [] notification. For example:

{
  "operationType_Read": {
    "object": "montage/data/service/data-operation[ReadOperationType]"
  },
  "root": {
    "prototype": "montage/data/service/data-operation",
    "values": {
      "type": {"@": "operationType_Read"}
    }
  }
}

@hthetiot hthetiot added this to the v17.3.x Data milestone May 21, 2018
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