Categorygithub.com/mymmrac/routines
repositorypackage
0.1.1
Repository: https://github.com/mymmrac/routines.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

:recycle: Routines

Go Reference Go Version Go Report

Simple way to write blocking operations in non-blocking functions/loops without concurrency and with no dependencies.

go get -u github.com/mymmrac/routines@latest

:jigsaw: Example

Simple hello world with "animated" loader.

Demo example
package main

import (
	"fmt"
	"time"

	"github.com/mymmrac/routines"
)

func main() {
	r := routines.StartRoutine()
	for !r.Completed() {
		r.Do(func() {
			fmt.Println("Hello Routines!")
			fmt.Print("Loading")
		})
		r.Repeat(3, func() {
			r.WaitFor(time.Second / 2)
			r.Do(func() {
				fmt.Print(".")
			})
		})
		r.Do(func() {
			fmt.Println()
			fmt.Println("Done!")
		})
		r.End()
	}
}

:stars: Features

Routines have two types of controls: actions and waiters. All controls work only after Start and until End.

ActionDescription
StartStart routine execution
EndFinish routine execution
DoPerform an action
FuncCall func with other actions inside
LoopCall actions in loop
RepeatRepeat actions N times
WaiterDescription
WaitForWait for time to pass
WaitUntilWait for condition to be true
WaitUntilOrTimeoutWait for condition to be true or time to pass
WaitForDoneWait for chan value to be received
WaitForDoneOrTimeoutWait for chan value to be received or time to pass

:closed_lock_with_key: License

Distributed under MIT licence.