Events: Difference between revisions
Rename Perl 6 -> Raku, alphabetize, minor clean-up
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
|||
Line 224:
2016:10:18:07.94 : Event received by task: reset
</pre>
=={{header|Delphi}}==
<lang Delphi>program Events;
Line 535 ⟶ 536:
->
</pre>
=={{header|JavaScript}}==▼
An example using the [[wp:Yahoo!_UI_Library|YUI]] library:▼
<lang javascript>YUI().use('event-custom', function(Y) {▼
// add a custom event:▼
Y.on('my:event', function () {▼
alert("Event fired");▼
});▼
// fire the event after one second:▼
setTimeout(function () {▼
Y.fire('my:event');▼
}, 1000);▼
});</lang>▼
An example simulating [[wp:Document_Object_Model|DOM]] events:▼
<lang javascript>YUI().use('node-event-simulate', function(Y) {▼
// add a click event handler to a DOM node with id "button":▼
Y.one("#button").on("click", function (e) {▼
alert("Button clicked");▼
});▼
// simulate the click after one second:▼
setTimeout(function () {▼
Y.one("#button").simulate("click");▼
}, 1000);▼
});</lang>▼
=={{header|Julia}}==
Line 650 ⟶ 675:
WM_MOUSEWHEEL = 522
mx.msg_listen([WM_COPYDATA, WM_MOUSEWHEEL], VOID, #msgReceived)</lang>
▲=={{header|JavaScript}}==
▲An example using the [[wp:Yahoo!_UI_Library|YUI]] library:
▲<lang javascript>YUI().use('event-custom', function(Y) {
▲ // add a custom event:
▲ Y.on('my:event', function () {
▲ alert("Event fired");
▲ });
▲ // fire the event after one second:
▲ setTimeout(function () {
▲ Y.fire('my:event');
▲ }, 1000);
▲});</lang>
▲An example simulating [[wp:Document_Object_Model|DOM]] events:
▲<lang javascript>YUI().use('node-event-simulate', function(Y) {
▲ // add a click event handler to a DOM node with id "button":
▲ Y.one("#button").on("click", function (e) {
▲ alert("Button clicked");
▲ });
▲ // simulate the click after one second:
▲ setTimeout(function () {
▲ Y.one("#button").simulate("click");
▲ }, 1000);
▲});</lang>
=={{header|Mathematica}}==
Line 881 ⟶ 882:
$quit->recv;</lang>
=={{header|Perl 6}}==▼
{{trans|Go}}▼
<lang perl6>note now, " program start";▼
my $event = Channel.new;▼
my $todo = start {▼
note now, " task start";▼
$event.receive;▼
note now, " event reset by task";▼
}▼
note now, " program sleeping";▼
sleep 1;▼
note now, " program signaling event";▼
$event.send(0);▼
await $todo;</lang>▼
{{out}}▼
<pre>Instant:1403880984.089974 program start▼
Instant:1403880984.095400 program sleeping▼
Instant:1403880984.095491 task start▼
Instant:1403880985.099381 program signaling event▼
Instant:1403880985.109395 event reset by task</pre>▼
See also [[Handle_a_signal#Perl_6]] for an example of using Supplies to do reactive programming based on events (Unix signals in this case).▼
=={{header|Phix}}==
Line 1,070 ⟶ 1,046:
(void (sync task)) ; wait for the task to be done before exiting
</lang>
(formerly Perl 6)
▲{{trans|Go}}
▲<lang perl6>note now, " program start";
▲my $event = Channel.new;
▲my $todo = start {
▲ note now, " task start";
▲ $event.receive;
▲ note now, " event reset by task";
▲}
▲note now, " program sleeping";
▲sleep 1;
▲note now, " program signaling event";
▲$event.send(0);
▲await $todo;</lang>
▲{{out}}
▲<pre>Instant:1403880984.089974 program start
▲Instant:1403880984.095400 program sleeping
▲Instant:1403880984.095491 task start
▲Instant:1403880985.099381 program signaling event
▲Instant:1403880985.109395 event reset by task</pre>
▲See also [[Handle_a_signal#Perl_6]] for an example of using Supplies to do reactive programming based on events (Unix signals in this case).
=={{header|REXX}}==
|