-
Notifications
You must be signed in to change notification settings - Fork 22
Doc awareness #277
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
Doc awareness #277
Changes from 2 commits
7845ff7
dc91692
3aa8387
c1b0496
a8af145
8c74b23
4612306
8c780d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -5,6 +5,7 @@ | |||||
from typing import Any, Callable, Dict, Optional | ||||||
|
||||||
from pycrdt import Doc, Map, Subscription, UndoManager | ||||||
from pycrdt_websocket.awareness import Awareness | ||||||
|
||||||
|
||||||
class YBaseDoc(ABC): | ||||||
|
@@ -20,7 +21,7 @@ class YBaseDoc(ABC): | |||||
_subscriptions: Dict[Any, Subscription] | ||||||
_undo_manager: UndoManager | ||||||
|
||||||
def __init__(self, ydoc: Optional[Doc] = None): | ||||||
def __init__(self, ydoc: Optional[Doc] = None, awareness: Optional[Awareness] = None): | ||||||
""" | ||||||
Constructs a YBaseDoc. | ||||||
|
||||||
|
@@ -31,6 +32,9 @@ def __init__(self, ydoc: Optional[Doc] = None): | |||||
self._ydoc = Doc() | ||||||
else: | ||||||
self._ydoc = ydoc | ||||||
|
||||||
self._awareness = awareness | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should just have:
Suggested change
And remove the getter and setter as they do nothing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or maybe we should only remove the setter, to make There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed the getter and setter. |
||||||
|
||||||
brichet marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
self._ystate = self._ydoc.get("state", type=Map) | ||||||
self._subscriptions = {} | ||||||
self._undo_manager = UndoManager(doc=self._ydoc, capture_timeout_millis=0) | ||||||
|
@@ -74,6 +78,25 @@ def ydoc(self) -> Doc: | |||||
""" | ||||||
return self._ydoc | ||||||
|
||||||
@property | ||||||
def awareness(self) -> Awareness | None: | ||||||
brichet marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
""" | ||||||
Return the awareness. | ||||||
brichet marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
:return: The document's awareness. | ||||||
:rtype: :class:`pycrdt_websocket.awareness.Awareness` | ||||||
brichet marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
""" | ||||||
return self._awareness | ||||||
|
||||||
@awareness.setter | ||||||
def awareness(self, value: Awareness): | ||||||
brichet marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
""" | ||||||
Sets the awareness. | ||||||
|
||||||
:param: The awareness. | ||||||
""" | ||||||
self._awareness = value | ||||||
|
||||||
@property | ||||||
def source(self) -> Any: | ||||||
""" | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.