documentation: add JS api docs
[project/luci.git] / documentation / jsapi / LuCI.Poll.html
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta charset="utf-8">
5 <title>JSDoc: Class: Poll</title>
6
7 <script src="scripts/prettify/prettify.js"> </script>
8 <script src="scripts/prettify/lang-css.js"> </script>
9 <!--[if lt IE 9]>
10 <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11 <![endif]-->
12 <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13 <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14 </head>
15
16 <body>
17
18 <div id="main">
19
20 <h1 class="page-title">Class: Poll</h1>
21
22
23
24
25
26
27 <section>
28
29 <header>
30
31 <h2><span class="attribs"><span class="type-signature"></span></span>
32 <span class="ancestors"><a href="LuCI.html">LuCI</a>.</span>Poll</h2>
33
34 <div class="class-description"><p>The <code>Poll</code> class allows registering and unregistering poll actions,
35 as well as starting, stopping and querying the state of the polling
36 loop.</p></div>
37
38
39 </header>
40
41 <article>
42 <div class="container-overview">
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 <dl class="details">
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87 <dt class="tag-source">Source:</dt>
88 <dd class="tag-source"><ul class="dummy"><li>
89 <a href="luci.js.html">luci.js</a>, <a href="luci.js.html#line999">line 999</a>
90 </li></ul></dd>
91
92
93
94
95
96
97
98 </dl>
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120 </div>
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137 <h3 class="subsection-title">Methods</h3>
138
139
140
141
142
143
144
145 <h4 class="name" id="active"><span class="type-signature"></span>active<span class="signature">()</span><span class="type-signature"> &rarr; {boolean}</span></h4>
146
147
148
149
150
151
152 <div class="description">
153 <p>Test whether the polling loop is running.</p>
154 </div>
155
156
157
158
159
160
161
162
163
164
165
166
167
168 <dl class="details">
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195 <dt class="tag-source">Source:</dt>
196 <dd class="tag-source"><ul class="dummy"><li>
197 <a href="luci.js.html">luci.js</a>, <a href="luci.js.html#line1150">line 1150</a>
198 </li></ul></dd>
199
200
201
202
203
204
205
206 </dl>
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222 <h5>Returns:</h5>
223
224
225 <div class="param-desc">
226 <ul>
227 <li>Returns <code>true</code> if polling is active, else <code>false</code>.</li>
228 </ul>
229 </div>
230
231
232
233 <dl>
234 <dt>
235 Type
236 </dt>
237 <dd>
238
239 <span class="param-type">boolean</span>
240
241
242 </dd>
243 </dl>
244
245
246
247
248
249
250
251
252
253
254
255
256
257 <h4 class="name" id="add"><span class="type-signature"></span>add<span class="signature">(fn, interval)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
258
259
260
261
262
263
264 <div class="description">
265 <p>Add a new operation to the polling loop. If the polling loop is not
266 already started at this point, it will be implicitely started.</p>
267 </div>
268
269
270
271
272
273
274
275
276
277 <h5>Parameters:</h5>
278
279
280 <table class="params">
281 <thead>
282 <tr>
283
284 <th>Name</th>
285
286
287 <th>Type</th>
288
289
290
291
292
293 <th class="last">Description</th>
294 </tr>
295 </thead>
296
297 <tbody>
298
299
300 <tr>
301
302 <td class="name"><code>fn</code></td>
303
304
305 <td class="type">
306
307
308 <span class="param-type">function</span>
309
310
311
312 </td>
313
314
315
316
317
318 <td class="description last"><p>The function to invoke on each poll interval.</p></td>
319 </tr>
320
321
322
323 <tr>
324
325 <td class="name"><code>interval</code></td>
326
327
328 <td class="type">
329
330
331 <span class="param-type">number</span>
332
333
334
335 </td>
336
337
338
339
340
341 <td class="description last"><p>The poll interval in seconds.</p></td>
342 </tr>
343
344
345 </tbody>
346 </table>
347
348
349
350
351
352
353 <dl class="details">
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380 <dt class="tag-source">Source:</dt>
381 <dd class="tag-source"><ul class="dummy"><li>
382 <a href="luci.js.html">luci.js</a>, <a href="luci.js.html#line1023">line 1023</a>
383 </li></ul></dd>
384
385
386
387
388
389
390
391 </dl>
392
393
394
395
396
397
398
399
400
401
402
403
404
405 <h5>Throws:</h5>
406
407
408
409 <dl>
410 <dt>
411 <div class="param-desc">
412 <p>Throws <code>TypeError</code> when an invalid interval was passed.</p>
413 </div>
414 </dt>
415 <dd></dd>
416 <dt>
417 <dl>
418 <dt>
419 Type
420 </dt>
421 <dd>
422
423 <span class="param-type">TypeError</span>
424
425
426 </dd>
427 </dl>
428 </dt>
429 <dd></dd>
430 </dl>
431
432
433
434
435
436 <h5>Returns:</h5>
437
438
439 <div class="param-desc">
440 <p>Returns <code>true</code> if the function has been added or <code>false</code> if it
441 already is registered.</p>
442 </div>
443
444
445
446 <dl>
447 <dt>
448 Type
449 </dt>
450 <dd>
451
452 <span class="param-type">boolean</span>
453
454
455 </dd>
456 </dl>
457
458
459
460
461
462
463
464
465
466
467
468
469
470 <h4 class="name" id="remove"><span class="type-signature"></span>remove<span class="signature">(fn)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
471
472
473
474
475
476
477 <div class="description">
478 <p>Remove an operation from the polling loop. If no further operatons
479 are registered, the polling loop is implicitely stopped.</p>
480 </div>
481
482
483
484
485
486
487
488
489
490 <h5>Parameters:</h5>
491
492
493 <table class="params">
494 <thead>
495 <tr>
496
497 <th>Name</th>
498
499
500 <th>Type</th>
501
502
503
504
505
506 <th class="last">Description</th>
507 </tr>
508 </thead>
509
510 <tbody>
511
512
513 <tr>
514
515 <td class="name"><code>fn</code></td>
516
517
518 <td class="type">
519
520
521 <span class="param-type">function</span>
522
523
524
525 </td>
526
527
528
529
530
531 <td class="description last"><p>The function to remove.</p></td>
532 </tr>
533
534
535 </tbody>
536 </table>
537
538
539
540
541
542
543 <dl class="details">
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570 <dt class="tag-source">Source:</dt>
571 <dd class="tag-source"><ul class="dummy"><li>
572 <a href="luci.js.html">luci.js</a>, <a href="luci.js.html#line1064">line 1064</a>
573 </li></ul></dd>
574
575
576
577
578
579
580
581 </dl>
582
583
584
585
586
587
588
589
590
591
592
593
594
595 <h5>Throws:</h5>
596
597
598
599 <dl>
600 <dt>
601 <div class="param-desc">
602 <p>Throws <code>TypeError</code> when the given argument isn't a function.</p>
603 </div>
604 </dt>
605 <dd></dd>
606 <dt>
607 <dl>
608 <dt>
609 Type
610 </dt>
611 <dd>
612
613 <span class="param-type">TypeError</span>
614
615
616 </dd>
617 </dl>
618 </dt>
619 <dd></dd>
620 </dl>
621
622
623
624
625
626 <h5>Returns:</h5>
627
628
629 <div class="param-desc">
630 <p>Returns <code>true</code> if the function has been removed or <code>false</code> if it
631 wasn't found.</p>
632 </div>
633
634
635
636 <dl>
637 <dt>
638 Type
639 </dt>
640 <dd>
641
642 <span class="param-type">boolean</span>
643
644
645 </dd>
646 </dl>
647
648
649
650
651
652
653
654
655
656
657
658
659
660 <h4 class="name" id="start"><span class="type-signature"></span>start<span class="signature">()</span><span class="type-signature"> &rarr; {boolean}</span></h4>
661
662
663
664
665
666
667 <div class="description">
668 <p>(Re)start the polling loop. Dispatches a custom <code>poll-start</code> event
669 to the <code>document</code> object upon successful start.</p>
670 </div>
671
672
673
674
675
676
677
678
679
680
681
682
683
684 <dl class="details">
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711 <dt class="tag-source">Source:</dt>
712 <dd class="tag-source"><ul class="dummy"><li>
713 <a href="luci.js.html">luci.js</a>, <a href="luci.js.html#line1090">line 1090</a>
714 </li></ul></dd>
715
716
717
718
719
720
721
722 </dl>
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738 <h5>Returns:</h5>
739
740
741 <div class="param-desc">
742 <p>Returns <code>true</code> if polling has been started (or if no functions
743 where registered) or <code>false</code> when the polling loop already runs.</p>
744 </div>
745
746
747
748 <dl>
749 <dt>
750 Type
751 </dt>
752 <dd>
753
754 <span class="param-type">boolean</span>
755
756
757 </dd>
758 </dl>
759
760
761
762
763
764
765
766
767
768
769
770
771
772 <h4 class="name" id="stop"><span class="type-signature"></span>stop<span class="signature">()</span><span class="type-signature"> &rarr; {boolean}</span></h4>
773
774
775
776
777
778
779 <div class="description">
780 <p>Stop the polling loop. Dispatches a custom <code>poll-stop</code> event
781 to the <code>document</code> object upon successful stop.</p>
782 </div>
783
784
785
786
787
788
789
790
791
792
793
794
795
796 <dl class="details">
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823 <dt class="tag-source">Source:</dt>
824 <dd class="tag-source"><ul class="dummy"><li>
825 <a href="luci.js.html">luci.js</a>, <a href="luci.js.html#line1115">line 1115</a>
826 </li></ul></dd>
827
828
829
830
831
832
833
834 </dl>
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850 <h5>Returns:</h5>
851
852
853 <div class="param-desc">
854 <p>Returns <code>true</code> if polling has been stopped or <code>false</code> if it din't
855 run to begin with.</p>
856 </div>
857
858
859
860 <dl>
861 <dt>
862 Type
863 </dt>
864 <dd>
865
866 <span class="param-type">boolean</span>
867
868
869 </dd>
870 </dl>
871
872
873
874
875
876
877
878
879
880
881
882
883
884 </article>
885
886 </section>
887
888
889
890
891 </div>
892
893 <nav>
894 <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="LuCI.html">LuCI</a></li><li><a href="LuCI.Class.html">Class</a></li><li><a href="LuCI.dom.html">dom</a></li><li><a href="LuCI.fs.html">fs</a></li><li><a href="LuCI.Headers.html">Headers</a></li><li><a href="LuCI.Network.html">Network</a></li><li><a href="LuCI.Network.Device.html">Device</a></li><li><a href="LuCI.Network.Hosts.html">Hosts</a></li><li><a href="LuCI.Network.Protocol.html">Protocol</a></li><li><a href="LuCI.Network.WifiDevice.html">WifiDevice</a></li><li><a href="LuCI.Network.WifiNetwork.html">WifiNetwork</a></li><li><a href="LuCI.Poll.html">Poll</a></li><li><a href="LuCI.Request.html">Request</a></li><li><a href="LuCI.Request.poll.html">poll</a></li><li><a href="LuCI.Response.html">Response</a></li><li><a href="LuCI.rpc.html">rpc</a></li><li><a href="LuCI.uci.html">uci</a></li><li><a href="LuCI.view.html">view</a></li><li><a href="LuCI.XHR.html">XHR</a></li></ul>
895 </nav>
896
897 <br class="clear">
898
899 <footer>
900 Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Tue Nov 05 2019 09:33:05 GMT+0100 (Central European Standard Time)
901 </footer>
902
903 <script> prettyPrint(); </script>
904 <script src="scripts/linenumber.js"> </script>
905 </body>
906 </html>