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

feat(core): improve type signatures #58

Merged
merged 4 commits into from
Dec 19, 2016

Conversation

TylorS
Copy link
Member

@TylorS TylorS commented Dec 19, 2016

Improves the Type Signatures of DriverFn, Sources, and Sinks.

BREAKING CHANGES: DriverFn is now a Generic. Sources and Sinks types are always objects.

@Frikki Frikki self-requested a review December 19, 2016 20:04
@Frikki Frikki self-assigned this Dec 19, 2016
Copy link
Member

@Frikki Frikki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good.

@@ -51,6 +51,7 @@
}
},
"devDependencies": {
"@motorcycle/tslint": "1.2.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"tslint": "^4.0.0-dev.1",
"typescript": "^2.1.0-dev.20161109",
"tslint": "^4.1.1",
"typescript": "^2.1.4",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[key: string]: T;
}

export interface Component<Sources extends Object<Source>, Sinks extends Object<Sink<any>>> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -4,19 +4,23 @@ import { Subject, sync, next, error, complete } from 'most-subject';
export type Sink<T> = Stream<T>;
export type Source = any;

export interface Component<Sources, Sinks> {
export interface Object<T> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export interface DriverFn {
<T, R>(sink: Sink<T>): R;
export interface DriverFn<T, R> {
(sink: Sink<T>): R;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -53,7 +57,7 @@ function callDrivers<Sources, Sinks> (drivers: Drivers, sinkProxies: Sinks): Sou
}, {} as Sources);
}

function callComponent<Sources, Sinks> (
function callComponent<Sources extends Object<Source>, Sinks extends Object<Source>> (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -130,7 +130,7 @@ describe('Motorcycle Core', () => {

it('prints errors to the console', (done) => {
const sandbox = sinon.sandbox.create();
sandbox.stub(console, `error`);
const stub = sandbox.stub(console, `error`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -143,7 +143,7 @@ describe('Motorcycle Core', () => {
Motorcycle.run(main, {other: driver});

setTimeout(() => {
sinon.assert.calledOnce(console.error as Sinon.SinonSpy);
sinon.assert.calledOnce(stub);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"check-operator",
"check-separator",
"check-type"]
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"check-separator",
"check-type"]
}
"extends": [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Frikki Frikki merged commit 013d167 into master Dec 19, 2016
@Frikki Frikki deleted the tylors/feat/improve-type-signatures branch December 19, 2016 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants