Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphs instantiating twice #608

Open
sfescape opened this issue Aug 13, 2018 · 2 comments
Open

Graphs instantiating twice #608

sfescape opened this issue Aug 13, 2018 · 2 comments

Comments

@sfescape
Copy link

When using asCallback I noticed that two graph instances are being instantiated for each graph component.

@bergie
Copy link
Member

bergie commented Aug 16, 2018

@sfescape can you provide an example to verify this?

@sfescape
Copy link
Author

sfescape commented Aug 16, 2018

I took the example from the documentation for embedding (simple graph that just repeats in to core/Display).

`"use strict";

// Load the NoFlo module
const noflo = require('noflo')

// Use NoFlo's asCallback helper to prepare a JS function that wraps the graph
const wrappedGraph = noflo.asCallback('show_flow', {
// Provide the project base directory where NoFlo seeks graphs and components
baseDir: process.cwd()
})

// Call the wrapped graph. Can be done multiple times
wrappedGraph({
// Provide data to be sent to inports
in: 'foo',
}, (err, result) => {
// If component sent to its error port, then we'll have err
if (err) { throw err }
// Do something with the results
//console.log(result.out)
})`

I added a console.log to component/Graph.js just before the graph loadFile call.

if (graph.substr(0, 1) !== "/" && graph.substr(1, 1) !== ":" && process && process.cwd) { graph =${process.cwd()}/${graph}; } console.log('load graph file', graph) return noflo.graph.loadFile(graph, (err, instance) => {

Execute the graph and observe that the show_flow graph is loaded twice.

load graph file .../graphs/show_flow.fbp load graph file .../graphs/show_flow.fbp

Note: the graph itself only executes once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants