mirror of
https://github.com/status-im/realm-js.git
synced 2025-02-02 09:46:28 +00:00
Rename realm delegate in transact_log_handler as well
This commit is contained in:
parent
4973827531
commit
70e1967782
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#include "transact_log_handler.hpp"
|
#include "transact_log_handler.hpp"
|
||||||
|
|
||||||
#include "realm_delegate.hpp"
|
#include "../realm_binding_context.hpp"
|
||||||
|
|
||||||
#include <realm/commit_log.hpp>
|
#include <realm/commit_log.hpp>
|
||||||
#include <realm/group_shared.hpp>
|
#include <realm/group_shared.hpp>
|
||||||
@ -28,15 +28,15 @@ using namespace realm;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
class TransactLogHandler {
|
class TransactLogHandler {
|
||||||
using ColumnInfo = RealmDelegate::ColumnInfo;
|
using ColumnInfo = RealmBindingContext::ColumnInfo;
|
||||||
using ObserverState = RealmDelegate::ObserverState;
|
using ObserverState = RealmBindingContext::ObserverState;
|
||||||
|
|
||||||
// Observed table rows which need change information
|
// Observed table rows which need change information
|
||||||
std::vector<ObserverState> m_observers;
|
std::vector<ObserverState> m_observers;
|
||||||
// Userdata pointers for rows which have been deleted
|
// Userdata pointers for rows which have been deleted
|
||||||
std::vector<void *> invalidated;
|
std::vector<void *> invalidated;
|
||||||
// Delegate to send change information to
|
// Delegate to send change information to
|
||||||
RealmDelegate* m_delegate;
|
RealmBindingContext* m_binding_context;
|
||||||
|
|
||||||
// Index of currently selected table
|
// Index of currently selected table
|
||||||
size_t m_current_table = 0;
|
size_t m_current_table = 0;
|
||||||
@ -84,33 +84,33 @@ class TransactLogHandler {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
template<typename Func>
|
template<typename Func>
|
||||||
TransactLogHandler(RealmDelegate* delegate, SharedGroup& sg, Func&& func)
|
TransactLogHandler(RealmBindingContext* binding_context, SharedGroup& sg, Func&& func)
|
||||||
: m_delegate(delegate)
|
: m_binding_context(binding_context)
|
||||||
{
|
{
|
||||||
if (!delegate) {
|
if (!binding_context) {
|
||||||
func();
|
func();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_observers = delegate->get_observed_rows();
|
m_observers = binding_context->get_observed_rows();
|
||||||
if (m_observers.empty()) {
|
if (m_observers.empty()) {
|
||||||
auto old_version = sg.get_version_of_current_transaction();
|
auto old_version = sg.get_version_of_current_transaction();
|
||||||
func();
|
func();
|
||||||
if (old_version != sg.get_version_of_current_transaction()) {
|
if (old_version != sg.get_version_of_current_transaction()) {
|
||||||
delegate->did_change({}, {});
|
binding_context->did_change({}, {});
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
func(*this);
|
func(*this);
|
||||||
delegate->did_change(m_observers, invalidated);
|
binding_context->did_change(m_observers, invalidated);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called at the end of the transaction log immediately before the version
|
// Called at the end of the transaction log immediately before the version
|
||||||
// is advanced
|
// is advanced
|
||||||
void parse_complete()
|
void parse_complete()
|
||||||
{
|
{
|
||||||
m_delegate->will_change(m_observers, invalidated);
|
m_binding_context->will_change(m_observers, invalidated);
|
||||||
}
|
}
|
||||||
|
|
||||||
// These would require having an observer before schema init
|
// These would require having an observer before schema init
|
||||||
@ -318,28 +318,28 @@ public:
|
|||||||
namespace realm {
|
namespace realm {
|
||||||
namespace _impl {
|
namespace _impl {
|
||||||
namespace transaction {
|
namespace transaction {
|
||||||
void advance(SharedGroup& sg, ClientHistory& history, RealmDelegate* delegate) {
|
void advance(SharedGroup& sg, ClientHistory& history, RealmBindingContext* binding_context) {
|
||||||
TransactLogHandler(delegate, sg, [&](auto&&... args) {
|
TransactLogHandler(binding_context, sg, [&](auto&&... args) {
|
||||||
LangBindHelper::advance_read(sg, history, std::move(args)...);
|
LangBindHelper::advance_read(sg, history, std::move(args)...);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void begin(SharedGroup& sg, ClientHistory& history, RealmDelegate* delegate) {
|
void begin(SharedGroup& sg, ClientHistory& history, RealmBindingContext* binding_context) {
|
||||||
TransactLogHandler(delegate, sg, [&](auto&&... args) {
|
TransactLogHandler(binding_context, sg, [&](auto&&... args) {
|
||||||
LangBindHelper::promote_to_write(sg, history, std::move(args)...);
|
LangBindHelper::promote_to_write(sg, history, std::move(args)...);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void commit(SharedGroup& sg, ClientHistory&, RealmDelegate* delegate) {
|
void commit(SharedGroup& sg, ClientHistory&, RealmBindingContext* binding_context) {
|
||||||
LangBindHelper::commit_and_continue_as_read(sg);
|
LangBindHelper::commit_and_continue_as_read(sg);
|
||||||
|
|
||||||
if (delegate) {
|
if (binding_context) {
|
||||||
delegate->did_change({}, {});
|
binding_context->did_change({}, {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cancel(SharedGroup& sg, ClientHistory& history, RealmDelegate* delegate) {
|
void cancel(SharedGroup& sg, ClientHistory& history, RealmBindingContext* binding_context) {
|
||||||
TransactLogHandler(delegate, sg, [&](auto&&... args) {
|
TransactLogHandler(binding_context, sg, [&](auto&&... args) {
|
||||||
LangBindHelper::rollback_and_continue_as_read(sg, history, std::move(args)...);
|
LangBindHelper::rollback_and_continue_as_read(sg, history, std::move(args)...);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#define REALM_TRANSACT_LOG_HANDLER_HPP
|
#define REALM_TRANSACT_LOG_HANDLER_HPP
|
||||||
|
|
||||||
namespace realm {
|
namespace realm {
|
||||||
class RealmDelegate;
|
class RealmBindingContext;
|
||||||
class SharedGroup;
|
class SharedGroup;
|
||||||
class ClientHistory;
|
class ClientHistory;
|
||||||
|
|
||||||
@ -28,19 +28,19 @@ namespace _impl {
|
|||||||
namespace transaction {
|
namespace transaction {
|
||||||
// Advance the read transaction version, with change notifications sent to delegate
|
// Advance the read transaction version, with change notifications sent to delegate
|
||||||
// Must not be called from within a write transaction.
|
// Must not be called from within a write transaction.
|
||||||
void advance(SharedGroup& sg, ClientHistory& history, RealmDelegate* delegate);
|
void advance(SharedGroup& sg, ClientHistory& history, RealmBindingContext* binding_context);
|
||||||
|
|
||||||
// Begin a write transaction
|
// Begin a write transaction
|
||||||
// If the read transaction version is not up to date, will first advance to the
|
// If the read transaction version is not up to date, will first advance to the
|
||||||
// most recent read transaction and sent notifications to delegate
|
// most recent read transaction and sent notifications to delegate
|
||||||
void begin(SharedGroup& sg, ClientHistory& history, RealmDelegate* delegate);
|
void begin(SharedGroup& sg, ClientHistory& history, RealmBindingContext* binding_context);
|
||||||
|
|
||||||
// Commit a write transaction
|
// Commit a write transaction
|
||||||
void commit(SharedGroup& sg, ClientHistory& history, RealmDelegate* delegate);
|
void commit(SharedGroup& sg, ClientHistory& history, RealmBindingContext* binding_context);
|
||||||
|
|
||||||
// Cancel a write transaction and roll back all changes, with change notifications
|
// Cancel a write transaction and roll back all changes, with change notifications
|
||||||
// for reverting to the old values sent to delegate
|
// for reverting to the old values sent to delegate
|
||||||
void cancel(SharedGroup& sg, ClientHistory& history, RealmDelegate* delegate);
|
void cancel(SharedGroup& sg, ClientHistory& history, RealmBindingContext* binding_context);
|
||||||
} // namespace transaction
|
} // namespace transaction
|
||||||
} // namespace _impl
|
} // namespace _impl
|
||||||
} // namespace realm
|
} // namespace realm
|
||||||
|
Loading…
x
Reference in New Issue
Block a user