• jQuery慢慢啃之回调(十三)


    1.callbacks.add(callbacks)//回调列表中添加一个回调或回调的集合

    // a sample logging function to be added to a callbacks list
    var foo = function( value ){
        console.log( 'foo:' + value );
    }
    
    // another function to also be added to the list
    var bar = function( value ){
        console.log( 'bar:' + value );
    }
    
    var callbacks = $.Callbacks();
    
    // add the function 'foo' to the list
    callbacks.add( foo );
    
    // fire the items on the list
    callbacks.fire( 'hello' );  
    // outputs: 'foo: hello'
    
    // add the function 'bar' to the list
    callbacks.add( bar );
    
    // fire the items on the list again
    callbacks.fire( 'world' );  
    
    // outputs:
    // 'foo: world'
    // 'bar: world'

    2.callbacks.disable()//禁用回调列表中的回调 

    // a sample logging function to be added to a callbacks list
    var foo = function( value ){
        console.log( value );
    }
    
    var callbacks = $.Callbacks();
    
    // add the above function to the list
    callbacks.add( foo );
    
    // fire the items on the list
    callbacks.fire( 'foo' ); // outputs: foo
    
    // disable further calls being possible
    callbacks.disable();
    
    // attempt to fire with 'foobar' as an argument
    callbacks.fire( 'foobar' ); // foobar isn't output

    3.callbacks.empty()//从列表中删除所有的回调.

    // a sample logging function to be added to a callbacks list
    var foo = function( value1, value2 ){
        console.log( 'foo:' + value1 + ',' + value2 );
    }
    
    // another function to also be added to the list
    var bar = function( value1, value2 ){
        console.log( 'bar:' + value1 + ',' + value2 );
    }
    
    var callbacks = $.Callbacks();
    
    // add the two functions
    callbacks.add( foo );
    callbacks.add( bar );
    
    // empty the callbacks list
    callbacks.empty();
    
    // check to ensure all callbacks have been removed
    console.log( callbacks.has( foo ) ); // false
    console.log( callbacks.has( bar ) ); // false

    4.callbacks.fire(arguments)//禁用回调列表中的回调 

    // a sample logging function to be added to a callbacks list
    var foo = function( value ){
        console.log( 'foo:' + value );
    }
    
    var callbacks = $.Callbacks();
    
    // add the function 'foo' to the list
    callbacks.add( foo );
    
    // fire the items on the list
    callbacks.fire( 'hello' ); // outputs: 'foo: hello'
    callbacks.fire( 'world '); // outputs: 'foo: world'
    
    // add another function to the list
    var bar = function( value ){
        console.log( 'bar:' + value );
    } 
    
    // add this function to the list
    callbacks.add( bar );
    
    // fire the items on the list again
    callbacks.fire( 'hello again' );
    // outputs:
    // 'foo: hello again'
    // 'bar: hello again'

    5.callbacks.fired()//用给定的参数调用所有的回调。

    // a sample logging function to be added to a callbacks list
    var foo = function( value ){
        console.log( 'foo:' + value );
    }
    
    var callbacks = $.Callbacks();
    
    // add the function 'foo' to the list
    callbacks.add( foo );
    
    // fire the items on the list
    callbacks.fire( 'hello' ); // outputs: 'foo: hello'
    callbacks.fire( 'world '); // outputs: 'foo: world'
    
    // test to establish if the callbacks have been called
    console.log( callbacks.fired() );

    6.callbacks.fireWith([context][,args])//访问给定的上下文和参数列表中的所有回调

    7.callbacks.has(callback)//确定是否提供的回调列表 

    8.callbacks.lock()//锁定在其当前状态的回调列表。 

    9.callbacks.locked()//确定是否已被锁定的回调列表

    10.callbacks.remove(callbacks)//删除回调或回调回调列表的集合。 

    11.jQuery.callbacks(flags)//一个多用途的回调列表对象,提供了强大的的方式来管理回调函数列表。

  • 相关阅读:
    利用vuex 做个简单的前端缓存
    EFcore 解决 SQLite 没有datetime 类型的问题
    dotnet 清理 nuget 缓存
    .net 5 单文件模式发布异常 CodeBase is not supported on assemblies loaded from a single-file bundle
    ubuntu 开启ip转发的方法
    Vue-ECharts 6 迁移记录
    System.Text.Json 5.0 已增加支持将Enum 由默认 Number类型 转换为String JsonStringEnumConverter
    Windows 10 LTSC 2019 正式版轻松激活教程
    Mac 提示Permission denied
    苹果手机代理 charles 提示(此链接非私人连接)
  • 原文地址:https://www.cnblogs.com/yuliantao/p/4277240.html
Copyright © 2020-2023  润新知