332 lines
16 KiB
HTML
332 lines
16 KiB
HTML
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
|
<title>The MathJax.Callback.Signal Class — MathJax v1.1 documentation</title>
|
|
<link rel="stylesheet" href="../_static/mj.css" type="text/css" />
|
|
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
|
<script type="text/javascript">
|
|
var DOCUMENTATION_OPTIONS = {
|
|
URL_ROOT: '../',
|
|
VERSION: '1.1',
|
|
COLLAPSE_INDEX: false,
|
|
FILE_SUFFIX: '.html',
|
|
HAS_SOURCE: true
|
|
};
|
|
</script>
|
|
<script type="text/javascript" src="../_static/jquery.js"></script>
|
|
<script type="text/javascript" src="../_static/underscore.js"></script>
|
|
<script type="text/javascript" src="../_static/doctools.js"></script>
|
|
<!--<script type="text/javascript" src="../../../MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>-->
|
|
<link rel="top" title="MathJax v1.1 documentation" href="../index.html" />
|
|
<link rel="up" title="The MathJax API" href="index.html" />
|
|
<link rel="next" title="The MathJax.InputJax Class" href="inputjax.html" />
|
|
<link rel="prev" title="The MathJax.Callback.Queue Class" href="queue.html" />
|
|
</head>
|
|
<body>
|
|
|
|
<div class="related">
|
|
<h3>Navigation</h3>
|
|
<ul>
|
|
<li class="right" style="margin-right: 10px">
|
|
<a href="../genindex.html" title="General Index"
|
|
accesskey="I">index</a></li>
|
|
<li class="right" >
|
|
<a href="inputjax.html" title="The MathJax.InputJax Class"
|
|
accesskey="N">next</a> |</li>
|
|
<li class="right" >
|
|
<a href="queue.html" title="The MathJax.Callback.Queue Class"
|
|
accesskey="P">previous</a> |</li>
|
|
<li><a href="../index.html">MathJax v1.1 documentation</a> »</li>
|
|
<li><a href="index.html" accesskey="U">The MathJax API</a> »</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="document">
|
|
<div class="documentwrapper">
|
|
<div class="bodywrapper">
|
|
<div class="body">
|
|
|
|
<div class="section" id="the-mathjax-callback-signal-class">
|
|
<span id="api-signal"></span><h1>The MathJax.Callback.Signal Class<a class="headerlink" href="#the-mathjax-callback-signal-class" title="Permalink to this headline">¶</a></h1>
|
|
<p>The <tt class="docutils literal"><span class="pre">MathJax.Callback.Signal</span></tt> object is one of the key mechanisms
|
|
used by MathJax to synchronize its actions with those that occur
|
|
asynchronously, like loading files and stylesheets. A <cite>Signal</cite> object
|
|
is used to publicize the fact that MathJax has performed certain
|
|
actions, giving other code running the web page the chance to react to
|
|
those actions. See <a class="reference internal" href="../synchronize.html#synchronization"><em>Synchronizing with MathJax</em></a> for more details, and <a class="reference internal" href="../signals.html#using-signals"><em>Using Signals</em></a> in particular for examples of how to specify and use
|
|
MathJax <cite>Signal</cite> objects.</p>
|
|
<p>The <cite>Callback Signal</cite> object is a subclass of the <a class="reference internal" href="queue.html#api-queue"><em>Callback Queue</em></a> object.</p>
|
|
<div class="section" id="properties">
|
|
<h2>Properties<a class="headerlink" href="#properties" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="describe">
|
|
<dt>
|
|
<tt class="descname">name</tt></dt>
|
|
<dd><p>The name of the signal. Each signal is named so that
|
|
various components can access it. The first one to request a
|
|
particular signal causes it to be created, and other requests for
|
|
the signal return references to the same object.</p>
|
|
</dd></dl>
|
|
|
|
<dl class="describe">
|
|
<dt>
|
|
<tt class="descname">posted</tt></dt>
|
|
<dd><p>Array used internally to store the post history so that when new
|
|
listeners express interests in this signal, they can be informed
|
|
of the signals that have been posted so far. This can be cleared
|
|
using the signal’s <a class="reference internal" href="message.html#Clear" title="Clear"><tt class="xref py py-meth docutils literal"><span class="pre">Clear()</span></tt></a> method.</p>
|
|
</dd></dl>
|
|
|
|
<dl class="describe">
|
|
<dt>
|
|
<tt class="descname">listeners</tt></dt>
|
|
<dd><p>Array of callbacks to the listeners who have expressed interest in
|
|
hearing about posts to this signal. When a post occurs, the
|
|
listeners are called, each in turn, passing them the message that
|
|
was posted.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="methods">
|
|
<h2>Methods<a class="headerlink" href="#methods" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="method">
|
|
<dt id="Post">
|
|
<tt class="descname">Post</tt><big>(</big><em>message</em><span class="optional">[</span>, <em>callback</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#Post" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Posts a message to all the listeners for the signal. The listener
|
|
callbacks are called in turn (with the message as an argument),
|
|
and if any return a <cite>Callback</cite> object, the posting will be
|
|
suspended until the callback is executed. In this way, the
|
|
<a class="reference internal" href="#Post" title="Post"><tt class="xref py py-meth docutils literal"><span class="pre">Post()</span></tt></a> call can operate asynchronously, and so the
|
|
<cite>callback</cite> parameter is used to synchronize with its operation;
|
|
the <cite>callback</cite> will be called when all the listeners have responded
|
|
to the post.</p>
|
|
<p>If a <a class="reference internal" href="#Post" title="Post"><tt class="xref py py-meth docutils literal"><span class="pre">Post()</span></tt></a> to this signal occurs while waiting for the
|
|
response from a listener (either because a listener returned a
|
|
<cite>Callback</cite> object and we are waiting for it to complete when the
|
|
<a class="reference internal" href="#Post" title="Post"><tt class="xref py py-meth docutils literal"><span class="pre">Post()</span></tt></a> occurred, or because the listener itself called the
|
|
<tt class="docutils literal"><span class="pre">Post()</span></tt> method), the new message will be queued and will be
|
|
posted after the current message has been sent to all the
|
|
listeners, and they have all responded. This is another way in
|
|
which posting can be asynchronous; the only sure way to know that
|
|
a posting has occurred is through its <cite>callback</cite>. When the posting
|
|
is complete, the callback is called, passing it the signal object
|
|
that has just completed.</p>
|
|
<p>Returns the callback object (or a blank callback object if none
|
|
was provided).</p>
|
|
<table class="docutils field-list" frame="void" rules="none">
|
|
<col class="field-name" />
|
|
<col class="field-body" />
|
|
<tbody valign="top">
|
|
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first simple">
|
|
<li><strong>message</strong> — the message to send through the signal</li>
|
|
<li><strong>callback</strong> — called after the message is posted</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
<tr class="field"><th class="field-name">Returns :</th><td class="field-body"><p class="first last">the callback or a blank callback</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</dd></dl>
|
|
|
|
<dl class="method">
|
|
<dt>
|
|
<tt class="descname">Clear</tt><big>(</big><span class="optional">[</span><em>callback</em><span class="optional">]</span><big>)</big></dt>
|
|
<dd><p>This causes the history of past messages to be cleared so new
|
|
listeners will not receive them. Note that since the signal may
|
|
be operating asynchronously, the <a class="reference internal" href="message.html#Clear" title="Clear"><tt class="xref py py-meth docutils literal"><span class="pre">Clear()</span></tt></a> may be queued for
|
|
later. In this way, the <a class="reference internal" href="#Post" title="Post"><tt class="xref py py-meth docutils literal"><span class="pre">Post()</span></tt></a> and <a class="reference internal" href="message.html#Clear" title="Clear"><tt class="xref py py-meth docutils literal"><span class="pre">Clear()</span></tt></a>
|
|
operations will be performed in the proper order even when they
|
|
are delayed. The <cite>callback</cite> is called when the <a class="reference internal" href="message.html#Clear" title="Clear"><tt class="xref py py-meth docutils literal"><span class="pre">Clear()</span></tt></a>
|
|
operation is completed.</p>
|
|
<p>Returns the callback (or a blank callback if none is provided).</p>
|
|
<table class="docutils field-list" frame="void" rules="none">
|
|
<col class="field-name" />
|
|
<col class="field-body" />
|
|
<tbody valign="top">
|
|
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first simple">
|
|
<li><strong>callback</strong> — called after the signal history is cleared</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
<tr class="field"><th class="field-name">Returns :</th><td class="field-body"><p class="first last">the callback or a blank callback</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</dd></dl>
|
|
|
|
<dl class="method">
|
|
<dt id="Interest">
|
|
<tt class="descname">Interest</tt><big>(</big><em>callback</em><span class="optional">[</span>, <em>ignorePast</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#Interest" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>This method registers a new listener on the signal. It creates a
|
|
<cite>Callback</cite> object from the callback specification, attaches it to
|
|
the signal, and returns that <cite>Callback</cite> object. When new messages
|
|
are posted to the signal, it runs the callback, passing it the
|
|
message that was posted. If the callback itself returns a
|
|
<cite>Callback</cite> object, that indicates that the listener has started an
|
|
asynchronous operation and the poster should wait for that
|
|
callback to complete before allowing new posts on the signal.</p>
|
|
<p>If <cite>ignorePast</cite> is <tt class="docutils literal"><span class="pre">false</span></tt> or not present, then before
|
|
<a class="reference internal" href="#Interest" title="Interest"><tt class="xref py py-meth docutils literal"><span class="pre">Interest()</span></tt></a> returns, the callback will be called with all
|
|
the past messages that have been sent to the signal.</p>
|
|
<table class="docutils field-list" frame="void" rules="none">
|
|
<col class="field-name" />
|
|
<col class="field-body" />
|
|
<tbody valign="top">
|
|
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first simple">
|
|
<li><strong>callback</strong> — called whenever a message is posted (past or present)</li>
|
|
<li><strong>ignorePast</strong> — <tt class="docutils literal"><span class="pre">true</span></tt> means ignore previous messages</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
<tr class="field"><th class="field-name">Returns :</th><td class="field-body"><p class="first last">the callback object</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</dd></dl>
|
|
|
|
<dl class="method">
|
|
<dt id="NoInterest">
|
|
<tt class="descname">NoInterest</tt><big>(</big><em>callback</em><big>)</big><a class="headerlink" href="#NoInterest" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>This removes a listener from the signal so that no new messages
|
|
will be sent to it. The callback should be the one returned by
|
|
the original <a class="reference internal" href="#Interest" title="Interest"><tt class="xref py py-meth docutils literal"><span class="pre">Interest()</span></tt></a> call that attached the listener to
|
|
the signal in the first place. Once removed, the listener will no
|
|
longer receive messages from the signal.</p>
|
|
<table class="docutils field-list" frame="void" rules="none">
|
|
<col class="field-name" />
|
|
<col class="field-body" />
|
|
<tbody valign="top">
|
|
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first simple">
|
|
<li><strong>callback</strong> — the listener to be removed from signal</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
<tr class="field"><th class="field-name">Returns :</th><td class="field-body"><p class="first last"><tt class="docutils literal"><span class="pre">null</span></tt></p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</dd></dl>
|
|
|
|
<dl class="method">
|
|
<dt id="MessageHook">
|
|
<tt class="descname">MessageHook</tt><big>(</big><em>message</em>, <em>callback</em><big>)</big><a class="headerlink" href="#MessageHook" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>This creates a callback that is called whenever the signal posts
|
|
the given message. This is a little easier than having to write a
|
|
function that must check the message each time it is called.
|
|
Although the <cite>message</cite> here is a string, if a message posted to the
|
|
signal is an array, then only the first element of that array is
|
|
used to match against the message. That way, if a message contains an
|
|
identifier plus arguments, the hook will match the identifier and
|
|
still get called with the complete set of arguments.</p>
|
|
<p>Returns the <cite>Callback</cite> object that was produced.</p>
|
|
<table class="docutils field-list" frame="void" rules="none">
|
|
<col class="field-name" />
|
|
<col class="field-body" />
|
|
<tbody valign="top">
|
|
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first simple">
|
|
<li><strong>message</strong> — the message to look for from the signal</li>
|
|
<li><strong>callback</strong> — called when the message is posted</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
<tr class="field"><th class="field-name">Returns :</th><td class="field-body"><p class="first last">the callback object</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</dd></dl>
|
|
|
|
<dl class="method">
|
|
<dt id="ExecuteHook">
|
|
<tt class="descname">ExecuteHook</tt><big>(</big><em>message</em><big>)</big><a class="headerlink" href="#ExecuteHook" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Used internally to call the listeners when a particular
|
|
message is posted to the signal.</p>
|
|
<table class="docutils field-list" frame="void" rules="none">
|
|
<col class="field-name" />
|
|
<col class="field-body" />
|
|
<tbody valign="top">
|
|
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first simple">
|
|
<li><strong>message</strong> — the posted message</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
<tr class="field"><th class="field-name">Returns :</th><td class="field-body"><p class="first last"><tt class="docutils literal"><span class="pre">null</span></tt></p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sphinxsidebar">
|
|
<div class="sphinxsidebarwrapper">
|
|
<h3><a href="../index.html">Table Of Contents</a></h3>
|
|
<ul>
|
|
<li><a class="reference internal" href="#">The MathJax.Callback.Signal Class</a><ul>
|
|
<li><a class="reference internal" href="#properties">Properties</a></li>
|
|
<li><a class="reference internal" href="#methods">Methods</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
|
|
<h4>Previous topic</h4>
|
|
<p class="topless"><a href="queue.html"
|
|
title="previous chapter">The MathJax.Callback.Queue Class</a></p>
|
|
<h4>Next topic</h4>
|
|
<p class="topless"><a href="inputjax.html"
|
|
title="next chapter">The MathJax.InputJax Class</a></p>
|
|
<div id="searchbox" style="display: none">
|
|
<h3>Quick search</h3>
|
|
<form class="search" action="../search.html" method="get">
|
|
<input type="text" name="q" size="18" />
|
|
<input type="submit" value="Go" />
|
|
<input type="hidden" name="check_keywords" value="yes" />
|
|
<input type="hidden" name="area" value="default" />
|
|
</form>
|
|
<p class="searchtip" style="font-size: 90%">
|
|
Enter search terms or a module, class or function name.
|
|
</p>
|
|
</div>
|
|
<script type="text/javascript">$('#searchbox').show(0);</script>
|
|
</div>
|
|
</div>
|
|
<div class="clearer"></div>
|
|
</div>
|
|
<div class="related">
|
|
<h3>Navigation</h3>
|
|
<ul>
|
|
<li class="right" style="margin-right: 10px">
|
|
<a href="../genindex.html" title="General Index"
|
|
>index</a></li>
|
|
<li class="right" >
|
|
<a href="inputjax.html" title="The MathJax.InputJax Class"
|
|
>next</a> |</li>
|
|
<li class="right" >
|
|
<a href="queue.html" title="The MathJax.Callback.Queue Class"
|
|
>previous</a> |</li>
|
|
<li><a href="../index.html">MathJax v1.1 documentation</a> »</li>
|
|
<li><a href="index.html" >The MathJax API</a> »</li>
|
|
</ul>
|
|
</div>
|
|
<div class="footer">
|
|
© Copyright 2011 Design Science.
|
|
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
|
</div>
|
|
|
|
</body>
|
|
</html> |