Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/mobile/event: rename the event package #10444

Closed
rakyll opened this issue Apr 13, 2015 · 13 comments
Closed

x/mobile/event: rename the event package #10444

rakyll opened this issue Apr 13, 2015 · 13 comments

Comments

@rakyll
Copy link
Contributor

rakyll commented Apr 13, 2015

Package event summarizes itself with "Package event defines user input events." even though we have additional packages such as sensor now that provides user-invoked events.

We may like to scope the event package to touch events and rename it accordingly. Or we can make the required code reorgs to define sensor events in the event package.

cc/ @crawshaw @hyangah

@minux
Copy link
Member

minux commented Apr 14, 2015 via email

@rakyll
Copy link
Contributor Author

rakyll commented Apr 14, 2015

We don't need sub-packages.

event.Touch, event.Movement, event.Location sounds better to me.

@rakyll rakyll changed the title mobile/event: rename event package mobile/event: rename the event package Apr 14, 2015
@hyangah
Copy link
Contributor

hyangah commented Apr 14, 2015

can we start with listing what "events" we are interested in?

user input events: touch, key (hardware key press)
sensor input events: motion, location

what about interruption caused by notification or phone call, or configuration change events such as orientation change event?

@rakyll
Copy link
Contributor Author

rakyll commented Apr 14, 2015

We also need to cover events listed on #10442.

I'd focus on whether we need to share these event types between multiple packages or not. If we have to share, it's better to keep them all under event. If not, event types may live in their particular packages.

@rsc rsc changed the title mobile/event: rename the event package x/mobile/event: rename the event package Apr 14, 2015
@rsc rsc removed the repo-mobile label Apr 14, 2015
@ianlancetaylor ianlancetaylor added this to the Unreleased milestone Jun 3, 2015
@rakyll rakyll modified the milestones: Go1.5, Unreleased Jul 1, 2015
@nigeltao
Copy link
Contributor

nigeltao commented Jul 3, 2015

The x/mobile/event package has changed since this issue was first opened. Its package doc comment currently says, "This package defines a number of commonly used events... other packages may define their own events".

Other packages include things like what's currently x/mobile/exp/sensor (and third party packages outside of x/mobile), so a 'sensor event' type doesn't necessarily need to live in "package event": the qualified type name could be "sensor.Event" instead of "event.Sensor".

Given that, it might make sense to break up the x/mobile/event packages to push 'core event' types like event.Touch and event.Draw into x/mobile/event/touch and x/mobile/event/draw so that the type's qualified names are "touch.Event" and "draw.Event", consistent with third party "foo.Event". I am already in favor of a separate x/mobile/event/key package so you can say things like "key.Backspace" and "key.AudioVolumeUp", so it might make sense to have "key.Event" too.

OTOH it does mean that the x/mobile/event/draw package will literally be:

package draw
type Event struct{}

plus commentary, which hardly seems worth its own package, but it still might make sense for consistency.

I don't know which way I prefer yet. WDYT?

@rakyll
Copy link
Contributor Author

rakyll commented Jul 6, 2015

I would prefer each event to be organized in its own package in order to provide consistent organization for the third parties. But if we create a new package for each event type, we will suffer from the pollution of sub-packages under x/mobile/event. And unfortunately these sub-packages will have to be named after very commonly used words such as touch and draw. It might be a wiser choice to preserve these names for functionality exposed around touch and draw, rather than just exporting event types.

@nigeltao
Copy link
Contributor

nigeltao commented Jul 6, 2015

Just some thoughts, before I forget. I still haven't decided which way I fall here.

"package touch" and "package lifecycle" would let you say "touch.Event" and "lifecycle.Event", but also "touch.SequenceID" and "lifecycle.Stage" instead of "event.TouchSequenceID" and "event.LifecycleStage", so while these event/foo packages will be small, they won't all be nothing but a trivial "type Event struct{ etc }". A "package key" certainly won't be trivial if we add names for all the buttons like Backspace, plus modifier masks.

As for the name "draw", there's already an "image/draw" package in the standard library, so it may make sense to rename the event from "draw" to "paint" (or another bikeshed color).

@rakyll
Copy link
Contributor Author

rakyll commented Jul 6, 2015

Pros of having touch.Event over event.Touch:

  • Third parties can export event types in a consistent way.
  • Names are shorter, user code will look less verbose.

Cons:

  • Name collisions within the mobile package. If we want to provide utility functions for touch events, we need to find another package name. Since there are numerous events we support and will support in the future, we are reserving numerous good names to export event types.
  • Name collisions with the standard library.
  • It is not clear to me where the common types (such as Change) are going to live at? x/mobile/event?

@rakyll rakyll removed this from the Go1.5 milestone Jul 11, 2015
@nigeltao
Copy link
Contributor

I'm now leaning towards package x/mobile/event/touch and touch.Event (and config.Event, key.Event, etc.), and removing the event.Change type back in favor of touch.TypeStart, touch.TypeEnd, key.TypePress, key.TypeRelease, etc.

What's left in the x/mobile/event package would be:

func Filter(event interface{}) interface{}
func RegisterFilter(f func(interface{}) interface{})

These could move to package app, so there is no "package event".

I'm not so concerned about name collisions, apart from s/draw.Event/paint.Event/ as I said above.

Any thoughts, @crawshaw, @hyangah, @rakyll?

@crawshaw
Copy link
Member

SGTM. My experiments with the scribe package (which I'll will return to when done with the machinery for publishing Ivy's source) pushed me towards the same opinion.

@hyangah
Copy link
Contributor

hyangah commented Jul 14, 2015

SGTM. let's do it before Go1.5

I am fine with leaving the event package though - could be the central place for overview documentation.

@rakyll
Copy link
Contributor Author

rakyll commented Jul 14, 2015

SGTM.

@gopherbot
Copy link

CL https://golang.org/cl/12225 mentions this issue.

@golang golang locked and limited conversation to collaborators Jul 18, 2016
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 10, 2021
Fixes golang/go#10444

Change-Id: Ie5a8ab8a09b1b1a4f7037da7cf945d39ab6a98fc
Reviewed-on: https://go-review.googlesource.com/12225
Reviewed-by: David Crawshaw <crawshaw@golang.org>
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 11, 2021
Fixes golang/go#10444

Change-Id: Ie5a8ab8a09b1b1a4f7037da7cf945d39ab6a98fc
Reviewed-on: https://go-review.googlesource.com/12225
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants