Skip to content
This repository has been archived by the owner on Jun 16, 2020. It is now read-only.

support two way data binding #64

Open
2 of 3 tasks
Raynos opened this issue Jul 18, 2014 · 14 comments
Open
2 of 3 tasks

support two way data binding #64

Raynos opened this issue Jul 18, 2014 · 14 comments
Labels

Comments

@Raynos
Copy link
Owner

Raynos commented Jul 18, 2014

  • observ-struct
  • observ-varhash
  • observ-array

cc @nrw

@Raynos
Copy link
Owner Author

Raynos commented Jul 18, 2014

I'm not going to fix observ-array tonight.

There's a bunch of complexity in this problem domain. observ-struct was hard enough.

@kumavis kumavis added the TODO label Feb 6, 2015
@kuraga
Copy link
Collaborator

kuraga commented Feb 11, 2015

@Raynos can you please describe the problem? thanks

@tracker1
Copy link

@Raynos this may provide some insight... not sure if it's too slow though... but thought it might help...

https://github.com/benjamine/jsondiffpatch

@Raynos
Copy link
Owner Author

Raynos commented Feb 11, 2015

I think we fixed observ-array, cannot remember.

@Raynos
Copy link
Owner Author

Raynos commented Feb 11, 2015

See this issue ( Raynos/observ-array#9 ). cc @kuraga

I never verified whether all the edgecases were handled.

Also see nrw/observ-varhash#1

@kuraga
Copy link
Collaborator

kuraga commented Feb 11, 2015

Hm... It's difficult to understand, when notes about issues are posted in different components' repositories 😄

@Raynos
Copy link
Owner Author

Raynos commented Feb 11, 2015

@kuraga distributed conversations :) hard to find them.

It's also not fully documented what two way data binding means. it basically means that if you mutate either the parent or child in both the parent & child get updated.

var parentArr = hg.array();
var childArr = hg.array();

parentArr.push(childArr);

childArr.push(4);
parentArr.get(0).get(0) === 4;

parentArr.set([
  [5]
])
childArr.get(0) === 4;
parentArr.get(0).get(0) === 5;

I'm not really sure what I want the semantics to be in all the edge cases tbh... Whatever makes time travel work.

The whole point is to be able to serialize the entire state of the world at any time and bring it back at any other time. which means appState.set(bigComplexObject) should propogate the changes down correctly to all the places.

@kuraga
Copy link
Collaborator

kuraga commented Feb 21, 2015

An ObservVarhash is a version of observ-struct that allows adding and removing keys. Mutation of an observable element in the hash will cause the ObservVarhash to emit a new changed plain javascript object.

@nrw does it mean than we can use observ-varhash as a replacement of observ-struct in mercury?

@nrw
Copy link
Collaborator

nrw commented Feb 21, 2015

@kuraga observ-varhash does everything that observ-struct does, so we could use it as a replacement. I always use struct when i know my keys are static and i use varhash when i know they'll change. are you just looking to reduce dependencies?

@kuraga
Copy link
Collaborator

kuraga commented Feb 21, 2015

I'm looking everything to understand every line of mercury 😄

@nrw
Copy link
Collaborator

nrw commented Feb 21, 2015

i see. :)

If you look at the source, varhash is just struct with a bunch of bookkeeping for adding and removing keys. You could just use varhash all the time, if you like.

@Raynos
Copy link
Owner Author

Raynos commented Feb 21, 2015

I use struct to communicate "these are fixed keys"

I use varhash to communicate "there are N keys"

There is a different, a struct can be like struct({ n: string, m: number })
A varhash should be homogenous so each key should have the same shape varhash({ a: componentT, b: componentT })

@cellvia
Copy link

cellvia commented Mar 7, 2016

I'm not really sure what I want the semantics to be in all the edge cases tbh... Whatever makes time travel work.

@Raynos or anyone, could you explain this a little further (what would/wouldnt make time travel work, what are examples of edge cases in the context of Raynos sample above)? im a bit new to all this, but may contribute as im noticing observ-array being a bottleneck in my project

@Raynos
Copy link
Owner Author

Raynos commented Mar 7, 2016

@cellvia last time I looked at this I observed that using varhash instead of array is better in general.

Most of the time you have an array of objects; you can just create a varhash indexed by id or

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants