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

Decoupling vue-mc from RESTful APIs #155

Open
bshepherdson opened this issue Aug 20, 2020 · 1 comment
Open

Decoupling vue-mc from RESTful APIs #155

bshepherdson opened this issue Aug 20, 2020 · 1 comment

Comments

@bshepherdson
Copy link

I really like the patterns vue-mc brings! Thanks for building it and documenting it clearly.

I saw a question about GraphQL, and this might be similar. I'm working with a gRPC backend, not a JSON REST endpoint. Some of the RPCs it defines are very straightforward CRUD requests and could easily be adapted to the fetch/save/delete patterns of vue-mc.

However, the assumption that we're targeting a JSON REST API is deeply shot through the design and API of vue-mc.

Has there been any work on this front before? It seems sane in principle to use a Strategy pattern, so most of vue-mc is written against a generic request/response interface and then have REST, gRPC and other (including user-supplied) implementations.

With Vue 3 (and its new ref() reactivity system) in RC, is an overhaul of vue-mc planned or in progress? That might be a good time to make the changes I'm imaging.

@Skuudoer
Copy link

Skuudoer commented Aug 24, 2020

@shepheb,

I've done it via extending the model

import { fetch, save, remove } from './adapters/PouchDB'

...

export default class BaseModel extends Model {

...

 /**
   * Overide parent's @fetch method to retrive data from the database 
   *fetch
   * @param {*} document
   * @memberof BaseModel
   */
  fetch(document) {
    // call fetch from PouchDB
    fetch.call(this, document)
  }

...


  /**
   *Overide parent's @onFetchSuccess handler to retrive data from the database
   *onFetchSuccess
   * @param {*} snapshot
   * @returns document
   * @memberof BaseModel
   */
  onFetchSuccess(snapshot) {
    return snapshot;
  }

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

No branches or pull requests

2 participants