Skip to content
This repository has been archived by the owner on Jan 6, 2019. It is now read-only.

sheenobu/rxgen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rxgen

rxgen is a gen typewriter for generating reactive code

installation

gen add github.com/sheenobu/rxgen

Simple Usage

Outputs type RxRect:

// +gen rx
type Rect struct {
	X int
	Y int
	W int
	H int
}

Builtin types

you can annotate builtin types with a type alias and an underscore:

// +gen rx:"Builtin[uint]"
type Uint_ uint

Uint_ will be ignored and the output name will be Uint and wrap uint. Additionally, you can use build tags to exclude Uint_ from being included.

Usage

import (
   "lib"
)

r := NewUint(1)
r2 := NewRxRect(Rect{X: 0, Y: 0, W: 0, H: 0})

// Get the value
v := r.Get() // 1

// Create a new subscription
c := r.Subscribe()

go func() {
	r.Set(1234)  // blocks, triggers loop below
	r.Set(4321)  // blocks, triggers loop below

	c.Close() // closes subscription, quits loop below
}()

for val := range c.C {
	fmt.Printf("Integer changed value: %d\n", val)
}

About

typewriter for generating reactive code

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages