reactions: github.com/shurcooL/reactions Index | Examples | Files | Directories

package reactions

import "github.com/shurcooL/reactions"

Package reactions provides a reactions service definition.

Code:

package main

import (
    "fmt"
    "reflect"
    "strings"
)

/*func TestMapping(t *testing.T) {
	tests := []string{
		"32.5% 55%",
		"32.5% 42.5%",
	}
	for _, test := range tests {
		foo(test)
	}
}*/

func main() {
    in := "32.5% 55%"
    want := []string{"32.5%", "55%"}
    got := bar(in)

    fmt.Println(reflect.DeepEqual(got, want))

}

func bar(in string) []string {
    return strings.Fields(in)
}

/*func ExampleBaz() {
	in := "32.5%"
	want := 13
	got := baz(in)

	fmt.Println(reflect.DeepEqual(got, want))

	// Output: true
}*/

Index

Examples

Package Files

doc.go reactions.go service.go

Variables

var Sorted = []string{ /* 1292 elements not displayed */

}

func Position Uses

func Position(emojiID string) string

type EmojiID Uses

type EmojiID string

EmojiID is the id of a reaction. For example, "+1". TODO, THINK: Maybe keep the colons, i.e., ":+1:".

type Reaction Uses

type Reaction struct {
    Reaction EmojiID
    Users    []users.User // Length is 1 or more. First entry is first person who reacted.
}

Reaction represents a single reaction, backed by 1 or more users.

type Service Uses

type Service interface {
    // List all reactions at uri. Map key is reactable id.
    // uri is clean '/'-separated URI. E.g., "example.com/page".
    // If uri isn't a valid reactable URI, a not found error is returned.
    List(ctx context.Context, uri string) (map[string][]Reaction, error)

    // Get reactions for id at uri.
    // uri is clean '/'-separated URI. E.g., "example.com/page".
    // If uri/id doesn't point at a valid reactable target,
    // a not found error is returned.
    Get(ctx context.Context, uri string, id string) ([]Reaction, error)

    // Toggle a reaction for id at uri.
    // If uri/id doesn't point at a valid reactable target,
    // a not found error is returned.
    Toggle(ctx context.Context, uri string, id string, tr ToggleRequest) ([]Reaction, error)
}

Service defines methods of a reactions service.

type ToggleRequest Uses

type ToggleRequest struct {
    Reaction EmojiID
}

ToggleRequest is a request to toggle a reaction.

func (ToggleRequest) Validate Uses

func (ToggleRequest) Validate() error

Validate returns non-nil error if the request is invalid.

Directories

PathSynopsis
emojisPackage emojis contains emojis image data.
fsPackage fs implements reactions.Service using a virtual filesystem.
menu
mousemoveclickmousemoveclick is a script to demonstrate a peculiar browser behavior on iOS.

Package reactions imports 2 packages (graph) and is imported by 14 packages. Updated 2017-02-26. Refresh now. Tools for package owners.