{"json_modified": "2016-03-28T08:08:36.490031", "uuid": "d743afeb-e902-412d-ac64-6b1cee9980e6", "title": "Creating JavaScript callbacks in components", "url": "/en-US/docs/Mozilla/Creating_JavaScript_callbacks_in_components", "tags": ["XPCOM"], "translations": [], "modified": "2016-02-29T02:20:11", "label": "Creating JavaScript callbacks in components", "localization_tags": [], "locale": "en-US", "id": 9032, "last_edit": "2011-03-15T23:22:30", "summary": "XPCOM components use IDL to create interfaces. These interfaces are used to manipulate the component in C++ and JavaScript. A common pattern used with interfaces to create a bi-directional communication between two groups of code is the observer (or listener) pattern. Basically, the component defines an observer (or listener) interface which is implemented by some external code and this implementation is passed to the component. The component can then call methods on the observer interface to signal the external code when predefined events occur. Here is a very simple example of the observer pattern:", "sections": [{"id": "Callback_patterns_in_IDL", "title": "Callback patterns in IDL"}, {"id": "JavaScript_functions_as_callbacks", "title": "JavaScript functions as callbacks"}, {"id": "Revealing_the_magic", "title": "Revealing the magic"}], "slug": "Mozilla/Creating_JavaScript_callbacks_in_components", "review_tags": []}