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

Implement references to other objects that have an id property #16

Open
LeaVerou opened this issue Feb 10, 2016 · 1 comment
Open

Implement references to other objects that have an id property #16

LeaVerou opened this issue Feb 10, 2016 · 1 comment

Comments

@LeaVerou
Copy link
Member

As discussed with @karger today.

Idea: Strings that happen to be the same as some id property in the data structure can be dereferenced to the object that contains this property. In case of duplicate values, first (or last?) one wins.

Implementation thoughts:

  • We don’t want to introduce a performance hit if the strings are not dereferenced. That means accessors are out of the question. ES6 Proxies seem like the best way to do it.
  • array of all properties named id so we don’t have to traverse the entire tree.
@karger
Copy link
Collaborator

karger commented Feb 11, 2016

re duplicate ids. besides simple errors, the problem might also arise
if someone makes a wysie linking to several (other peoples'?) files that
aren't "coordinated" and replicate ids unintentionally.

"first mention" seems a fine first heuristic to deal with collisions.
and if someone is working with their own file they can fix it. but if
there are multiple files that the wysie author only reads, here are 2
other potential heuristics:

  1. prioritize the id that is in the same file as the referring object
  2. allow use of filenames as "namespace" or "types" to specify item
    locations, e.g. property="people.json:name"

On 2/10/2016 6:55 PM, Lea Verou wrote:

As discussed with @karger https://github.com/karger today.

Idea: Strings that happen to be the same as some |id| property in the
data structure can be dereferenced to the object that contains this
property. In case of duplicate values, first (or last?) one wins.

Implementation thoughts:

  • We don’t want to introduce a performance hit if the strings are
    not dereferenced. That means accessors are out of the question.
    ES6 Proxies seem like the best way to do it.
  • array of all properties named |id| so we don’t have to traverse
    the entire tree.


Reply to this email directly or view it on GitHub
https://github.com/LeaVerou/wysie/issues/16.

@LeaVerou LeaVerou added this to the 0.0.3 milestone Feb 11, 2016
@LeaVerou LeaVerou modified the milestones: 0.0.4, 0.0.3 Feb 17, 2016
@LeaVerou LeaVerou modified the milestones: 0.0.4, 0.0.5 Feb 26, 2016
@LeaVerou LeaVerou removed this from the 0.0.5 milestone Mar 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants