Comments (4)
Can you share an example on codepen/jsfiddle?
from lifecycle-plugin.
Hi, I don't have the time to prepare one right now. Take this example code:
export default class StreamLatestComponent extends Rete.Component {
constructor() {
super("StreamLatest");
}
onconnect(io) {
}
}
But I have two instances of StreamLatest like this:
When I connect something to one of the two components, the onconnect
method still gets called two times, since onconnect
is invoked via editor.getComponent(input.node.name).onconnect(input)
. From my understanding it should look for individiual nodes, something like this (probably not 100% right):
editor.on('connectioncreate', ({ input, output }) => {
let inputNode = editor.nodes.find(node => node.id == input.node.id);
let outputNode = editor.nodes.find(node => node.id == output.node.id);
return inputNode.onconnect(input) === true && outputNode.onconnect(output) === true;
});
Get my point? Or am I misunderstanding something?
My current workaround is to not use the lifecycle-plugin, but to do this in the component:
builder(node) {
this.editor.on("connectioncreate", ({ input, output }) => {
if(input.node.id !== node.id && output.node.id !== node.id)
return;
/* rest of code */
});
}
All the best!
from lifecycle-plugin.
onconnect method still gets called two times
This is the expected behavior, since onconnect
is called for Input and Output of two nodes you connect
from lifecycle-plugin.
Yeah I see, I re-thought this and see how your design was intended now. :) Cheers!
from lifecycle-plugin.
Related Issues (4)
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 lifecycle-plugin.