mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-11 14:54:33 +00:00
initial work on getting subscriptions to work in RN debugger (#1902)
* Getting subscriptions to work in RN debugger
This commit is contained in:
parent
d82c981386
commit
805f3d0804
@ -18,11 +18,11 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import { objectTypes } from './constants';
|
||||
import { keys, objectTypes } from './constants';
|
||||
import { getterForProperty, createMethods } from './util';
|
||||
import { deserialize } from './rpc';
|
||||
|
||||
export default class Subscription {
|
||||
|
||||
}
|
||||
|
||||
Object.defineProperties(Subscription.prototype, {
|
||||
@ -36,3 +36,13 @@ createMethods(Subscription.prototype, objectTypes.SUBSCRIPTION, [
|
||||
'addListener',
|
||||
'removeListener'
|
||||
]);
|
||||
|
||||
export function createSubscription(realmId, info) {
|
||||
let subscription = Object.create(Subscription.prototype);
|
||||
|
||||
subscription[keys.realm] = "(Subscription object)";
|
||||
subscription[keys.id] = info.id;
|
||||
subscription[keys.type] = objectTypes.SUBSCRIPTION;
|
||||
|
||||
return subscription;
|
||||
};
|
12
src/rpc.cpp
12
src/rpc.cpp
@ -45,6 +45,7 @@ static const char * const RealmObjectTypesResults = "results";
|
||||
static const char * const RealmObjectTypesRealm = "realm";
|
||||
static const char * const RealmObjectTypesUser = "user";
|
||||
static const char * const RealmObjectTypesSession = "session";
|
||||
static const char * const RealmObjectTypeSubscription = "subscription";
|
||||
static const char * const RealmObjectTypesUndefined = "undefined";
|
||||
|
||||
json serialize_object_schema(const realm::ObjectSchema &object_schema) {
|
||||
@ -569,6 +570,17 @@ json RPCServer::serialize_json_value(JSValueRef js_value) {
|
||||
{"data", session_dict}
|
||||
};
|
||||
}
|
||||
else if (jsc::Object::is_instance<js::SubscriptionClass<jsc::Types>>(m_context, js_object)) {
|
||||
json subscription_dict {
|
||||
{"state", serialize_json_value(jsc::Object::get_property(m_context, js_object, "state"))},
|
||||
{"error", serialize_json_value(jsc::Object::get_property(m_context, js_object, "error"))}
|
||||
};
|
||||
return {
|
||||
{"type", RealmObjectTypeSubscription},
|
||||
{"id", store_object(js_object)},
|
||||
{"data", subscription_dict}
|
||||
};
|
||||
}
|
||||
else if (jsc::Value::is_array(m_context, js_object)) {
|
||||
uint32_t length = jsc::Object::validated_get_length(m_context, js_object);
|
||||
std::vector<json> array;
|
||||
|
Loading…
x
Reference in New Issue
Block a user