Skip to content

updated clear () to clear the tracer screen #37

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

Closed
wants to merge 1 commit into from
Closed

updated clear () to clear the tracer screen #37

wants to merge 1 commit into from

Conversation

duaraghav8
Copy link
Member

@duaraghav8 duaraghav8 commented May 24, 2016

I've inserted 1 line in the clear () function in tracer.js in order to perform the clearing of screen upon calling tracer._clear ()
If this wasn't the intended behavior, then please ignore this request

I've inserted line 22 in order to perform the clearing of screen upon calling tracer._clear ()
If this wasn't the intended behavior, then please ignore this proposal.
@64json
Copy link
Member

64json commented May 24, 2016

I intended _clear method in Tracer to clear just the visualizing module, not the logs in the tracer tab.
It is my bad that I didn't put comments beside methods.
I'm planning to move those printing methods into separate tracer, e.g. LogTracer.

@64json 64json closed this May 24, 2016
@duaraghav8
Copy link
Member Author

Oh ok.
Also, there's one more thing I was thinking about.
We need a way for tracer to notify us once it has performed a particular function.

If we want to execute a statement right after the tracer has finished doing something, we currently cannot do it.

Take this simple code for example:

var tracer = new Array1DTracer ();
var array = [10, 20, 30, 90, 829];

tracer._setData (array);
for (var i = 0; i < array.length; i++) {
    tracer._select (i);
}

var newArray = [4,6,2,4,6,3,7];
tracer._setData (newArray);

One would expect that the screen displays the first array, selects all the items on-by-one, THEN changes the view to the newArray.
But instead, because of how tracers are implemented internally, it shows the first array. The moment we click "Run", it immediately changes the view to the newArray and selects items in the newArray.

This means we need the last tracer._select () to notify us that this action has been performed.
I can think of 3 ways to do this:

  1. use Callback with tracer functions like:
tracer._select (i, function () { console.log ('this comes after select'); });
  1. use Promises with tracer functions like:
tracer.select (i).then (function () { console.log ('this comes after select'); });
  1. Dispatch events from tracer functions like:
document.addEventListener ('cleared', function () { console.log ('screen cleared'); });
tracer._clear ();

What do you think?

@64json
Copy link
Member

64json commented May 24, 2016

Mhm, this might be a significant issue.
I guess I can fix it without callback functions.
I will let you know after I look over it again.
Thanks!

@duaraghav8 duaraghav8 deleted the patch-1 branch June 11, 2016 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants