What's the difference between a Deferred object and its own promise object?

后端 未结 3 610
悲&欢浪女
悲&欢浪女 2020-12-05 00:34

Let\'s create a simple Deferred object:

defer = $.Deferred( function ( defer ) {
    setTimeout( defer.resolve, 3000 );
});

The above Defer

3条回答
  •  我在风中等你
    2020-12-05 00:49

    When using the "promise" of a Deferred object the observers (objects waiting for resolve for exemple) dont have direct access to the Deferred object itself, so they can't call, for exemple, the method "Resolve" of that Deferred. It is a way of protecting the original Deferred.

提交回复
热议问题