diff options
Diffstat (limited to 'files/es/web/javascript/referencia/objetos_globales/object/unobserve/index.html')
| -rw-r--r-- | files/es/web/javascript/referencia/objetos_globales/object/unobserve/index.html | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/files/es/web/javascript/referencia/objetos_globales/object/unobserve/index.html b/files/es/web/javascript/referencia/objetos_globales/object/unobserve/index.html new file mode 100644 index 0000000000..d500dbde21 --- /dev/null +++ b/files/es/web/javascript/referencia/objetos_globales/object/unobserve/index.html @@ -0,0 +1,138 @@ +--- +title: Object.unobserve() +slug: Web/JavaScript/Referencia/Objetos_globales/Object/unobserve +tags: + - JavaScript + - No estandar + - Objeto + - metodo +translation_of: Archive/Web/JavaScript/Object.unobserve +--- +<div>{{JSRef}} {{non-standard_header}}</div> + +<p>El método <strong>Object.unobserve()</strong> es usado para remover observadores establecidos por {{jsxref("Object.observe()")}}.</p> + +<h2 id="Síntaxis">Síntaxis</h2> + +<pre class="syntaxbox"><code>Object.unobserve(<var>obj</var>, <var>callback</var>)</code></pre> + +<h3 id="Parametros">Parametros</h3> + +<dl> + <dt><code>obj</code></dt> + <dd>El objeto a parar de observar.</dd> + <dt><code>callback</code></dt> + <dd>La referencia al observador a parar de llamar cada vez que se hacen cambios sobre el objeto <strong>obj</strong>.</dd> +</dl> + +<h2 id="Descripción">Descripción</h2> + +<p><code>Object.unobserve()</code> debería ser llamado después de {{jsxref("Object.observe()")}} en orden de remover un observador de un objeto.</p> + +<p>La llamada de retorno (<em>callback</em>) debería ser una referencia a una función (asignada o declarada) y no a una función anonima, debido a que ésta referencia será usada para retirar el observador previo. A menos que se llame <strong><code>Object.unobserve()</code> </strong>con una función anonima como llamada de retorno, no se removerá ningún observador.</p> + +<h2 id="Ejemplos">Ejemplos</h2> + +<h3 id="Dejando_de_observar_un_objeto.">Dejando de observar un objeto.</h3> + +<pre class="brush: js">var obj = { + foo: 0, + bar: 1 +}; + +var observer = function(changes) { + console.log(changes); +} + +Object.observe(obj, observer); + +obj.newProperty = 2; +// [{name: 'newProperty', object: <obj>, type: 'add'}] + +Object.unobserve(obj, observer); + +obj.foo = 1; +// La llamada de retorno no fue llamada</pre> + +<h3 id="Utilizando_una_función_anónima">Utilizando una función anónima</h3> + +<pre class="brush: js">var person = { + name : 'Ahmed', + age : 25 +}; + +Object.observe(person, function (changes) { + console.log(changes); +}); + +person.age = 40; +// [{name: 'age', object: <obj>, oldValue: 25, type: 'update'}] + +Object.unobserve(person, function (changes) { + console.log(changes); +}); + +person.age = 63; +// [{name: 'age', object: <obj>, oldValue: 40, type: 'update'}] +// La llamada de retorno siempre será llamada +</pre> + +<h2 id="Compatibilidad_de_navegadores">Compatibilidad de navegadores</h2> + +<div>{{CompatibilityTable}}</div> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Caracteristica</th> + <th>Chrome</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>Soporte básico</td> + <td>{{CompatChrome("36")}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatOpera("23")}}</td> + <td>{{CompatNo}}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Caracteristica</th> + <th>Android</th> + <th>Chrome for Android</th> + <th>Firefox Mobile (Gecko)</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td>Soporte básico</td> + <td>{{CompatNo}}</td> + <td>{{CompatChrome("36")}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatOpera("23")}}</td> + <td>{{CompatNo}}</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="Ver_también">Ver también</h2> + +<ul> + <li>{{jsxref("Object.observe()")}} {{non-standard_inline}}</li> + <li>{{jsxref("Array.observe()")}} {{non-standard_inline}}</li> + <li>{{jsxref("Array.unobserve()")}} {{non-standard_inline}}</li> +</ul> |
