feed

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2020 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Example
package main

import (
	"image/color"

	"qlova.org/seed/client"
	"qlova.org/seed/new/app"
	"qlova.org/seed/new/button"
	"qlova.org/seed/new/feed"
	"qlova.org/seed/new/text"
	"qlova.org/seed/set/align"
	"qlova.org/seed/use/js"
	"qlova.org/seed/use/js/console"
)

func main() {
	var values = feed.With(func() []string {
		return []string{"a", "b", "c"}
	})

	app.New("Feed",
		button.New(text.Set("Click me"), client.OnClick(values.Refresh())),

		values.New(align.Center(),
			text.New(text.SetStringTo(js.String{Value: values.Data.GetValue()})),
			text.New(text.Set("hello"), text.SetColor(color.NRGBA{255, 0, 0, 255}),
				client.OnClick(console.Log(values.Data)),
			),
		),
	).Launch()
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Templates

func Templates(root seed.Seed) []seed.Seed

Types

type Feed

type Feed struct {
	Data Item

	Empty client.Bool
	// contains filtered or unexported fields
}

Feed has food ready to populate.

func With

func With(food Food, options ...seed.Option) *Feed

With returns a new Feed on the given Food, the options provided will be applied to the feed itself.

func (*Feed) Components

func (f *Feed) Components() []client.Value

Components implements client.Compound

func (*Feed) GetBool

func (f *Feed) GetBool() js.Bool

GetBool implements js.AnyBool

func (*Feed) GetValue

func (f *Feed) GetValue() js.Value

GetValue implements js.AnyValue

func (*Feed) Int

func (f *Feed) Int(field Field) client.Int

func (*Feed) New

func (f *Feed) New(options ...seed.Option) seed.Seed

New returns a new instantiated feed with the given options.

func (*Feed) Refresh

func (f *Feed) Refresh() client.Script

Refresh refreshes the feed.

func (*Feed) String

func (f *Feed) String(field Field) client.String

type Field

type Field interface {
	FieldName() string
}

Field can be used to select feed data.

func Get

func Get(name string) Field

Get converts a string into a field.

type Food

type Food interface{}

Food is fed to a feed to populate it with items.

func Filter

func Filter(food Food, fn func(Item) client.Bool) Food

Filter filters the food on the client with a given filter function.

func Go

func Go(f interface{}, args ...client.Value) Food

type Item

type Item struct {
	js.Value

	Index client.Int
	// contains filtered or unexported fields
}

Item is an individual element of a feed.

func (Item) Previous

func (item Item) Previous() Item

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL