You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the API for the Y data structures (YText, YArray, YMap) differs from the API for the equivalent Python structures (str, list, dict, respectively).
For instance:
Ypy
Python
ytext.extend(txn, "foo")
text += "foo"
yarray.insert_range(txn, 3, [5, 2])
l =l[:3] + [5, 2] + l[3:]
ymap.set(txn, "key", "value")
d["key"] = "value"
It seems to me that this is because the transaction object txn has to be passed around, and so I'm wondering if it has to be?
A transaction is tied to a document, and so are the root types. For instance in the following code:
ytext is a text root type of doc, and txn is the current transaction of doc. If txn were stored in doc, then ytext could have access to it, and there would be no need to pass it around, like so:
withdoc.begin_transaction(): # stores txn in docytext.extend("foo") # ytext, which is tied to doc, can access txn# then this becomes possible:# ytext += "foo"
I started experimenting with this idea in pycrdt, but maybe I'm missing something that will make this approach not viable.
Any feedback?
The text was updated successfully, but these errors were encountered:
Currently the API for the Y data structures (
YText
,YArray
,YMap
) differs from the API for the equivalent Python structures (str
,list
,dict
, respectively).For instance:
ytext.extend(txn, "foo")
text += "foo"
yarray.insert_range(txn, 3, [5, 2])
l =l[:3] + [5, 2] + l[3:]
ymap.set(txn, "key", "value")
d["key"] = "value"
It seems to me that this is because the transaction object
txn
has to be passed around, and so I'm wondering if it has to be?A transaction is tied to a document, and so are the root types. For instance in the following code:
ytext
is a text root type ofdoc
, andtxn
is the current transaction ofdoc
. Iftxn
were stored indoc
, thenytext
could have access to it, and there would be no need to pass it around, like so:I started experimenting with this idea in pycrdt, but maybe I'm missing something that will make this approach not viable.
Any feedback?
The text was updated successfully, but these errors were encountered: