Comments (4)
Better idea: introduce node visiting feature. Pass visitor like functor to receive full info about used nodes. Like
struct F
{
void operator()( node_info::id );
void operator()( node_info::depth );
void operator()( node_info::label );
void operator()( node_info::children );
void operator()( node_info::value<T> );
void operator()( node_info::type<T> );
// maybe node_type? signal/event/observer
};
context ctx;
ctx.peek_node_info( F() );
So user can use such info for whatever reason and convert it into needed format.
To achieve this context should have pointers to at least 0 depth nodes so we can iterate them. Also we need interface to add custom labels to nodes. This feature should be disableable using define, because it adds runtime overhead to store node pointers in context and to store label strings in nodes.
from ureact.
Maybe reimplementing of logging interface is fine too.
from ureact.
I think that it is easier to make it all via IListener interface that can be passed on the context creation. This interface will be analog of cpp.react's EventLog and IReactiveEngine. If user receive events about all the internal actions, then he can not only regenerate node graph on his side, but also see all the process, visualize it in any way he wants.
Here is combination of cpp.react's interfaces with descriptions:
struct IReactiveEngine
{
// Hard to understand that it means exactly.
// It is range between turn creation and actual change propagation
void OnTurnAdmissionStart(Turn& turn) {}
// No event
void OnTurnAdmissionEnd(Turn& turn) {}
// No event
// Change propagation
void Propagate(Turn& turn) {}
// No event
// Node creation/destruction
void OnNodeCreate(NodeT& node) {}
class NodeCreateEvent
void OnNodeDestroy(NodeT& node) {}
class NodeDestroyEvent
// Static attach/detach on creation/destruction
void OnNodeAttach(NodeT& node, NodeT& parent) {}
class NodeAttachEvent
void OnNodeDetach(NodeT& node, NodeT& parent) {}
class NodeDetachEvent
// Dynamic attach/detach in the process of change propagation. Needs extra actions, but basically the same
void OnDynamicNodeAttach(NodeT& node, NodeT& parent, Turn& turn) {}
class DynamicNodeAttachEvent
void OnDynamicNodeDetach(NodeT& node, NodeT& parent, Turn& turn) {}
class DynamicNodeDetachEvent
// Pulse means that IReactiveNode::Tick() did something, so children should be updated.
// IdlePulse means that IReactiveNode::Tick() did nothing
void OnNodePulse(NodeT& node, Turn& turn) {}
class NodePulseEvent
void OnNodeIdlePulse(NodeT& node, Turn& turn) {}
class NodeIdlePulseEvent
// Called inside IInputNode::ApplyInput(void* turnPtr) to notify that input node is triggered
// Basically the same as OnNodePulse, but for input nodes
void OnInputChange(NodeT& node, Turn& turn) {}
class InputNodeAdmissionEvent
// Events inside IReactiveNode::Tick(void* turn) that show where actual calculation is performed
class NodeEvaluateBeginEvent
class NodeEvaluateEndEvent
// Not used in legacy1 cpp.react
class TransactionBeginEvent
class TransactionEndEvent
class UserBreakpointEvent
};
Ureact has derived from cpp.react and evolved a little, so interface would differ. So, it is better to start from the easiest cases like nodes construction/destruction and their connections and continue form this.
Such logging facility is not free performance wise, so it should be optional and lay under some define that can disable it when it is not needed.
Unlike EventLog that has timestamps and tons of separate event classes with own serialization, I see ureact log interface as a IReactiveEngine's analog with tons of virtual methods which user should overload to be notified. So user can get the timestamp, and other info he likes.
Also, seeing tree of anonimous nodes which types, values etc we can't see it is not so informative, so need to come up with some idea how to add such info and pass it in the interface.
from ureact.
Also, it's good idea to make #125 first. Because otherwise logging interface will be in details namespace, because it uses classes and enumerations from this namespace.
from ureact.
Related Issues (20)
- Rework observer/scoped_observer/observe/tap
- Consider adding `transaction::finish()` method HOT 1
- Consider to support iterators as an observer argument HOT 1
- Make sure transactions can't be started or finished when turn is in progress HOT 1
- `adjustment` adapter possible improvements
- Make `Adaptor` `AdaptorClosure` and nodes part of public interface
- Try to mesure and improve compile times HOT 8
- Get rid of `ureact_amalgamated.hpp` HOT 1
- Make normal library mode (not header-only)
- First code example in doc/introduction.adoc does not compile HOT 5
- Consider adding dereference operator for signals
- Consider `connection_owner` idea from `PG1003/observer`
- Research how to implement Qt style property bindings HOT 2
- Compile errors for Visual Studio HOT 4
- Get rid of `issue_template.md` HOT 1
- Rework github actions
- `ureact::merge` can't compile in latest MSVC in c++20 mode HOT 3
- Consider making "event_source::operator<<" transaction wrapper HOT 1
- Research signal-slot library features
- Consider pitchfork project structure (aka PFL)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ureact.