def stop_drag(self, _): if self.dragging: self.dragging = False dynamics.animate( Object.to_js(self.c), {"x": 160, "y": 160}, {"type": dynamics.spring, "duration": 700, "friction": 280}, )
def __init__(self): firebase_cfg = { "apiKey": "", "authDomain": "XYZ.firebaseapp.com", "databaseURL": "https://XYZ.firebaseio.com", "projectId": "XYZ", "storageBucket": "XYZ.appspot.com", "messagingSenderId": "", "appId": "" } self.firebase = js_lib("firebase") self.firebase.initializeApp(Object.to_js(firebase_cfg)) self.database = self.firebase.firestore()
def save_todos(self, new, old): ToDoStorage.save(Object.to_py(new))
def subscribe(self, state, *args, **kwargs): object_storage["widgets"] = Object.to_py(state.widgets)
def test_dict(self): assert {"a": 1, "b": 2} == Object.from_js({"a": 1, "b": 2})
def test_array(self): with mock.patch.object(window.Array, "isArray", return_value=True): obj = Object.from_js(ArrayMock(1, 2, 3)) assert [1, 2, 3] == obj
def test_vue(self): class This: def _isVue(self): return True assert isinstance(Object.from_js(This()), VueInstance)
def get_prop(self, item): from vue.bridge import Object props = Object.to_py(self.store.props(self.widget_id)) return props.get(item, None)
def wrapper(*args, **kwargs): args = (javascript.this(), *args) if inject_vue_instance else args args = tuple(Object.from_js(arg) for arg in args) kwargs = {k: Object.from_js(v) for k, v in kwargs.items()} return Object.to_js(fn(*args, **kwargs))