In [5]:
%addjar http://localhost:8888/nbextensions/declarativewidgets/urth-widgets.jar
In [6]:
import declarativewidgets._
initWidgets
In [7]:
import declarativewidgets.WidgetChannels.channel
In [8]:
declarativewidgets.WidgetChannels
Out[8]:
In [9]:
%%html
<template is='urth-core-bind' channel='a'>
<div>Hello from <span>{{user}}</span></div>
Name: <input value='{{user::input}}'></input>
</template>
Out[9]:
In [10]:
%%html
<template is='urth-core-bind' channel='a'>
<div>Hello again from <span>[[user]]</span></div>
</template>
Out[10]:
import paper-slider widget
In [11]:
%%html
<link rel='import' href='urth_components/paper-slider/paper-slider.html'
is='urth-core-import' package='PolymerElements/paper-slider'>
Out[11]:
bind the value for x to channel A
In [21]:
%%html
<template is='urth-core-bind' channel='ch_A'>
<span>Channel A</span>
<table>
<tr>
<td>
<paper-slider
min="10"
max="100"
step="1"
value="[[x]]"/>
</td>
<td>
<span>[[x]]</span>
</td>
</tr>
</table>
</template>
Out[21]:
In [ ]:
In [33]:
%%html
<template is='urth-core-bind' channel='ch_A'>
<div>Hello again from <span>[[x]]</span></div>
</template>
Out[33]:
In [22]:
%AddDeps io.reactivex rxscala_2.10 0.26.1 --transitive
In [23]:
import java.util.concurrent.TimeUnit._
import scala.concurrent.duration.Duration
import rx.lang.scala.{Observer, Subscription, Observable}
import declarativewidgets.WidgetChannels.channel
Start a timer with 1 sec interval that posts to the channel "ch_A", bound to the paper-slider
In [36]:
val s1 = Duration(1, SECONDS)
val timer_sub =
Observable.
interval(s1, s1).
subscribe(onNext = (l) => channel("ch_A").set("x", l.toString))
In [37]:
timer_sub.unsubscribe()
In [14]:
%%html
<template is='urth-core-bind' channel='ch_FN'>
<div>Hello again <span>[[f]]</span></div>
</template>
Out[14]:
In [15]:
channel("ch_FN").set("f", (i: Int) => i+1)
In [18]:
val magic_sub =
Observable.
interval(s1, s1).
subscribe(onNext = (l) => kernel.magics.html(s"<h1>a title</h1><p>hello: $l</p>"))
In [39]:
val l = "test"
kernel.magics.html(s"<h1>a title</h1><p>hello: $l</p>")
Out[39]:
In [ ]: