-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Add .noConflict() functionality #8596
base: v1.2.x
Are you sure you want to change the base?
Conversation
hekike
commented
Aug 13, 2014
- add .noConflict() to the public api
Up! Would love to see this feature landing in an upcoming release! |
@caitp yes but I've solved the "resolve global JSONP conflicts" issue with a random callback hash instead of counter. |
I'm pretty sure this is going to break tests due to making callback IDs unpredictable (there are tests in httpBackendSpec.js which depend on this) You'd need to mock Math.random() to make those work |
@caitp do you mean for this line
|
No, I mean because you're generating a random key and adding it to the object rather than adding a predictable incremented number. |
But why do angular need an incremented number? |
Nah nevermind it should be fine, the tests use the replaced string to get the callbacks property name, so it doesn't matter. |
I'm sorry, but I wasn't able to verify your Contributor License Agreement (CLA) signature. CLA signature is required for any code contributions to AngularJS. Please sign our CLA and ensure that the CLA signature email address and the email address in this PR's commits match. If you signed the CLA as a corporation, please let us know the company's name. Thanks a bunch! PS: If you signed the CLA in the past then most likely the email addresses don't match. Please sign the CLA again or update the email address in the commit of this PR. |
@mary-poppins sry my author email address was wrong. Now it's okay. |
CLA signature verified! Thank you! Someone from the team will now triage your PR and it will be processed based on the determined priority (doc updates and fixes with tests are prioritized over other changes). |
Super interested in this feature. Hope it makes it in soon. |
472162d
to
466320f
Compare
Hello, I have been checking on this issue for a while now. Three months have passed since this PR, any chance to see this feature soon? it's a blocker for a lot of people who want to make third-party apps with Angular. |
+1 We would love to have this feature |
@@ -46,7 +46,7 @@ function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDoc | |||
url = url || $browser.url(); | |||
|
|||
if (lowercase(method) == 'jsonp') { | |||
var callbackId = '_' + (callbacks.counter++).toString(36); | |||
var callbackId = '_' + Math.random().toString(36).substring(7); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the "birthday paradox", if you have 100,000 callbacks, you will have a 6% chance of a collision. (See https://instacalc.com/28845, with "number of days" = 78364164096 = 36^7, and "number of people" = 100000.) So, I think this needs to be a longer random number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we only care for the callback id while the request is in flight, we care about the number of concurrent JSONP requests. If you had 100000 of them, then 6% callback id collision rate would be the least of your problems 😛