danschultz / frappe

A Dart package for functional reactive programming

Home Page:http://pub.dartlang.org/packages/frappe

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ideas around additional libraries

danschultz opened this issue · comments

Some ideas around additional libraries.

frappe/mouse.dart

A library that defines mouse input properties and events. Can be imported with import 'package:frappe/mouse.dart'.

final Property<Point> position

A property of the current mouse position.

final Property<bool> isPressed

A property indicating if the primary mouse button is pressed.

frappe/window.dart

A library that defines window properties and events. Can be imported with import 'package:frappe/window.dart'.

final Property<Rectangle> outerBounds

A property that contains the bounds of the current window, including browser chrome, UI controls, etc.

final Property<Rectangle> innerBounds

A property that contains the bounds of the current window, excluding browser chrome, UI controls, etc.

frappe/time.dart

A library that defines events for time. Can be imported with import 'package:frappe/time.dart'.

Stream<DateTime> every(Duration period)

Emits an event with a DateTime after each period.

Stream<Duration> fps(int frameRate)

Emits a duration at the desired frame rate, where duration is the time between the last frame and current frame.

Some cool ideas. One thing to be aware of is that frappe is currently usable outside the browser. Should not be an issue as long as you're careful what goes where

One thing to be aware of is that frappe is currently usable outside the browser. Should not be an issue as long as you're careful what goes where

Yup, mouse.dart and window.dart would depend on dart:html, time.dart would not. Hopefully this'd be obvious when using them, unless you can build UI's in Dart outside the browser one day.

The other option is to have html.dart, which would include window and mouse properties. But, you'd probably end up having to prefix the properties with window or mouse. For instance:

import 'package:frappe/html.dart';

mousePosition.listen(print);
windowInnerBounds.listen(print);

// as opposed to:

import 'package:frappe/mouse.dart' as mouse;
import 'package:frappe/window.dart' as window;

mouse.position.listen(print);
window.innerBounds.listen(print);

I like for syntax for the later case a bit more.

Or you could prefix window and mouse using classes inside html.dart...

// html.dart
library frappe.html;

class WindowProperties {
  final Property<Rectangle> innerBounds = new Property(...);
}

final window = new WindowProperties()

// main.dart
import 'package:frappe/html.dart';

window.innerBounds.listen(print);

I think mouse.dart and window.dart are fine. I'm just paranoid of any
browser dependencies sneaking into frappe.dart

Even though I'm using frappe in the browser, I've gone to great pains to
keep code that depends on dart:html to an absolute minimum. All my unit
tests that test all the frappe related code runs outside the browser.
On Tue, 3 Mar 2015 at 3:18 pm, Dan Schultz notifications@github.com wrote:

Or you could prefix window and mouse using classes inside html.dart...

class WindowProperties {
final Property innerBounds = new Property(...);
}
final window = new WindowProperties()
// main.dartimport 'package:frappe/html.dart';

window.innerBounds.listen(print);


Reply to this email directly or view it on GitHub
#33 (comment).