Bug Tracker

Modify

Ticket #11011 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 years ago

Allow traditional options object for $.Callbacks flags

Reported by: jaubourg Owned by:
Priority: low Milestone: 1.8
Component: deferred Version: 1.7.1
Keywords: 1.8-discuss Cc:
Blocking: Blocked by:

Description (last modified by mikesherov) (diff)

This enhancement is quite simple. There is some concern about $.Callbacks flags being in a string format. I propose to accept objects as an alternative so that you could do both of the following:

$.Callbacks( "once memory" );
$.Callbacks({
    once: true,
    memory: true
});

Change History

comment:1 Changed 2 years ago by jaubourg

  • Keywords 1.8-discuss added
  • Priority changed from undecided to low
  • Component changed from unfiled to deferred
  • Description modified (diff)

comment:2 Changed 2 years ago by jaubourg

  • Milestone changed from None to 1.8

comment:3 Changed 2 years ago by jaubourg

  • Description modified (diff)

+1

comment:4 follow-up: ↓ 5 Changed 2 years ago by dmethvin

  • Description modified (diff)

-1, I am not sure how this improves the interface (especially if we have to keep the old one) and I am pretty sure it will increase the size.

comment:5 in reply to: ↑ 4 Changed 2 years ago by jaubourg

Replying to dmethvin:

-1, I am not sure how this improves the interface (especially if we have to keep the old one) and I am pretty sure it will increase the size.

We're basically talking about replacing:

flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {};

with

flags = typeof flags === "string" ? ( flagsCache[ flags ] || createFlags( flags ) ) : ( flags || {} );

Are you being serious about the size Dave?

Regarding the gain, it's quite obviously easier and more natural to build an flags map compared to a string... not mention the possibility to add other (non-boolean) options in the future easily.

comment:6 Changed 2 years ago by dmethvin

  • Status changed from new to open

comment:7 Changed 2 years ago by timmywil

  • Description modified (diff)

+1

Last edited 2 years ago by timmywil (previous) (diff)

comment:8 Changed 2 years ago by mikesherov

  • Description modified (diff)

-1, YAGNI. If we ever have a need for an object version, we can add it then.

comment:9 Changed 2 years ago by rwaldron

+1

comment:10 Changed 2 years ago by dmethvin

+1, Changing my vote if it's that small, although the Callbacks api footprint is still an issue

comment:12 Changed 2 years ago by jaubourg

  • Status changed from open to closed
  • Resolution set to fixed

Allows traditional options object for $.Callbacks flags. Fixes #11011. Unit tests added.

Changeset: 7fa0da08b88534e486ddb7eb3752ef76467fb7dd

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.