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

Returning empty object when getting branch nodes (useful for decoupling deref) #951

Open
augonis opened this issue Nov 24, 2018 · 0 comments

Comments

@augonis
Copy link

augonis commented Nov 24, 2018

An example to illustrate.

var model = new falcor.Model({
  cache: {
    todos: {
      a:{
        name: 'get milk from corner store',
        done: false
      },
    }
  }});

model.get('todos.a').then(j => console.log(JSON.stringify(j, null, 2)))

//prints
{
  "json": {
    "todos": {
      "$__path": ["todos"]
    }
  }
}

There's no mention of the path I asked for (implying it doesn't exist?)
Instead I propose to make the response be

{
  "json": {
    "todos": {
      "$__path": ["todos"]
      "a": {
        "$__path": ["todos", "a"]
      }
    }
  }
}

It includes the requested path, indicating that there is something beyond there and giving its optimized path ripe for model.deref(). This is in line with Falcors philosophy of only returning what the client asked for.

This change would be most useful for a controller handing out dereferenced models to views.
One can imagine a generic list view that (itself been given a model dereferenced to an array) creating child views with models dereferenced to individual array items.
Currently it is impossible to dereference any item without knowledge of some leaf value within (or beyond) the item, preventing the creation of such truly generic list view.

I don't see this change would break something, but I might be wrong.

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

1 participant