This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Grooscript version of https://github.com/Reactive-Extensions/RxJS/tree/master/examples/autocomplete | |
import org.grooscript.asts.GsNative | |
import static org.grooscript.GrooScript.toJavascript | |
import static rxjs.ReactiveResolver.reactive | |
reactive { | |
def searchWikipedia = { term -> | |
$.ajax(url: 'http://en.wikipedia.org/w/api.php', | |
dataType: 'jsonp', | |
data: toJavascript([ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Grooscript version of https://github.com/Reactive-Extensions/RxJS/tree/master/examples/autocomplete | |
import groovy.transform.BaseScript | |
import org.grooscript.asts.GsNative | |
import static org.grooscript.GrooScript.toJavascript | |
@BaseScript | |
ReactiveScript baseScript | |
def keyUp = observeEvent(textInput, 'keyup') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def AwesomeProject = React.createClass( | |
render: { | |
def groovyView = new GroovyView() | |
groovyView.data(style: styles.container) { | |
image style: styles.image, source: [uri: 'http://grooscript.org/img/groovy.png'] | |
text style: styles.welcome, "Hello #ios from #groovylang" | |
text style: styles.welcome, "With @grooscript" | |
text style: styles.welcome, "and @reactjs native" | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.grooscript.asts.GsNative | |
class Faker { | |
private _faker | |
@GsNative | |
private faker() {/* | |
if (!this._faker) { | |
this._faker = require('faker'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GoogleMap.init { | |
options.zoom = 6 | |
options.center = ltlg(40.4379543,-3.6795367 ) | |
putStyle([ | |
[stylers: [ [ visibility: 'simplified' ],[ gamma: 0.5 ],[ weight: 0.5 ] ] ], | |
[featureType: 'water', stylers: [ [color: '#b77fd7'] ] ] | |
]) | |
mark(position: ltlg(40.4379543,-3.6795367), | |
title: 'grooscript', | |
icon: "img/gs.png" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.grooscript.asts.GsNative | |
trait JQueryRestApi { | |
static String url | |
static String resource | |
void add(Closure onSuccess, Closure onError) { | |
ajaxCall('POST', "${url}/${resource}", onSuccess, onError) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GrooscriptObservable.fromList(["one", "two", "three"]) | |
.take(2) | |
.subscribe({arg -> println(arg)}) | |
//In groovy and converted code in js, you get in console: | |
//one | |
//two | |
import org.grooscript.asts.GsNative |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Define your component in a groovy class | |
package foo.bar | |
class Counter { | |
static renderAfter = ['inc', 'dec'] | |
static style = 'button { background-color: red; }' | |
int value = 0 | |
void inc() { | |
value++ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package component | |
import todo.Todo | |
class MyTodo { | |
List<Todo> todos | |
String newTodoTyped | |
static renderAfter = ['gotTodos', 'newTaskAdded'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Elixir ideas https://quickleft.com/blog/pattern-matching-elixir/ | |
class Functions { | |
@When('!list') | |
int length(List list) { 0 } | |
@When('[heal | tail] = list') | |
int length(List list) { 1 + length(tail) } | |
OlderNewer