Skip to content

Intro to Custom Events: Uses API that no longer exists #475

Closed
outer89 opened this Issue Feb 27, 2014 · 10 comments

8 participants

@outer89
outer89 commented Feb 27, 2014

Hii!
I'm looking only now to jquery, and I was following your very nice tutorial.

wrt full example in http://learn.jquery.com/events/introduction-to-custom-events/ while triggering the call to twitter search api the following message is received:

jquery21009855909089092165_1393512219500({"errors":[{"message":"The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.","code":64}]});

the API are no more supported, it will be useful and nice to change the api version for having a good and full example working. This is one of the few complete example you have in your site under the learning center, and it will really be a pity to mess it up.

@mbdungo
mbdungo commented Mar 6, 2014

I second that motion! The simple "Twitter Search" application isn't working..
http://learn.jquery.com/events/introduction-to-custom-events/#a-sample-application

@siddharthm

The tutorial still uses API v1

@githubshrek githubshrek added a commit to githubshrek/learn.jquery.com that referenced this issue Jul 24, 2014
@githubshrek githubshrek warned users about broken app
Ideally the app should be updated (the subject of #475), but at least for now we should warn users.
6d0b770
@arthurvr
jQuery Foundation member
arthurvr commented Dec 6, 2014

Since v1.1 of the twitter API, this example application would get off-topic and too complicated. Any ideas for a better sample application, that would be 'easily' usable as an example?

@LorenzoGramola

Ideally there is the need of an application that either does not use a service subject to changes (or uses some services maintained by the community that return some simple data to be used) or change completely the example by providing another meaning to what custom events can be used for…

@gnarf gnarf self-assigned this Feb 24, 2015
@gnarf
jQuery Foundation member
gnarf commented Feb 24, 2015

I'm going to look closer at this soon and try to rewrite it, unless @arthurvr feels inspired and wants to take it before I get to it.

@arthurvr
jQuery Foundation member

Thanks @gnarf!

@gnarf gnarf changed the title from Twitter search api are old to Intro to Custom Events: Uses API that no longer exists Feb 24, 2015
@gnarf
jQuery Foundation member
gnarf commented Feb 24, 2015

Looking at this again - I really think we can just get rid of the entire "sample application" --- The document up until then does a pretty good job of explaining it and also supports the conclusion.

@gnarf
jQuery Foundation member
gnarf commented Feb 24, 2015

I mean http://learn.jquery.com/events/introduction-to-custom-events/#a-sample-application does this application actually provide anything concrete that I should try to reproduce in a new one?

@agcolom
jQuery Foundation member
agcolom commented Feb 25, 2015

@gnarf I think it's not critical, but would be nice to have. If there's an example you can think of, it would be great to have that added here to replace the twitter example. One of the objectives for us is to have more "real world" examples, so that would fit nicely. Otherwise, I agree that the article is well written and explains the topic clearly.

@scottgonzalez
jQuery Foundation member

A few comments about the article:

Using custom events with arbitrary names is dangerous as they may become standard in the future. Instead of changeState use something like lightbulb:change.

The sentence "If you're accustomed to object-oriented programming, you may find it useful to think of custom events as methods of objects" is pretty terrible advice. Events are not there for external users to trigger. They are not methods. In this sense, the article is fairly misleading, showing no real separation between who is listening for events and who is triggering events. The concept of a single "owner" of the event is not discussed. To show the confusion, we're attempting to separate the behavior between the switch and the lights, but an event (click) on the switch is directly triggering an event (turnOn/turnOff) on the lights. A lot of users end up writing code like this and then wonder why certain things don't work (because they're triggering events they don't own, thinking that the event is the cause of everything that happens when the event is normally triggered by the owner).

To be fair, the confusion starts with jQuery's built-in methods which are inverted from how the DOM works. In the DOM, a method like .focus() is actually a method that tells the element to take focus, which in turn triggers an event as the element tries to become focused. That is a very important difference from jQuery's .focus() which triggers and event and then detects if there was a native method that has an associated action.

@gnarf gnarf closed this in f9d0ab3 Feb 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.