Just to reiterate, whenever a user calls the show function inside of a code cell, I only want to execute
that call to show inside of this code cell's accompanying preview window.
So a call to show right here should be executed inside of this preview window, but not in the one down
here.
Let's take a look at how we can implement this.
All right, I want to first begin with just a quick reminder of what we are doing inside of our code
cell component, specifically inside of our selecter that we've been working on.
So inside there, I'm showing a diagram.
Just reflect what we were doing for code cell number two right now.
Inside that sector, we first begin by defining that cumulative code array and we stick in the show
function, and inside of that function is a bunch of logic to actually take a value and display it on
the screen.
Then inside of our four loop, we add in all the code for code cell number one and code cell number
two.
Whenever the code from code cell number one or number two try to call the show function, they're both
going to be accessing the show function we had injected at the very start of that array.
So they're both looking at that function right there.
Now, let's take a look at another diagram of what we are going to do to actually implement this new
feature, make sure that any color to show inside a code cell, no one don't actually get processed.
OK, here we go.
So all we're going to do is define multiple copies of the show function.
The very first entry that we're going to add into our array is going to be a copy of the show function
that does absolutely nothing when called.
Well, then add in all the code from code SEAL number one.
And then here's the critical part.
We're going to redefine the show function.
When we redefined the show function, we're going to put a version of the show function that actually
shows some content on the screen, and then immediately after that, we'll add in all the code for Code
Selt number two.
So think about what is going to happen now whenever we execute the bundled result of all this code.
Whenever we execute this, we're going to first define show.
We're going to define a version of it that does nothing.
What it is called will then have all the code from code cell number one if code.
So no one attempts to call show, it's going to call the version that does nothing at all.
We then redefined show.
We then run the code or add in the code for code cell number to be executed and any calls to the show
function for code cell number two are going to go to the redefined working version of the show function.
So this is how we're going to do it.
So now if no one ever calls show, nothing happens if Coatesville number two calls show, we're going
to actually go ahead and take the provided value and displayed on the screen.
That's it.
That's the trick.
Well, let's take a pause right here and then work on the implementation in just a moment.