Skip to content

Commit 2880d4c

Browse files
author
Vlad Balin
committedFeb 26, 2019
Merged from the master
2 parents 585d91f + 0fcb448 commit 2880d4c

File tree

15 files changed

+42
-31
lines changed

15 files changed

+42
-31
lines changed
 

Diff for: ‎dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ‎endpoints/attributes/dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ‎endpoints/localStorage/dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ‎endpoints/memory/dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ‎endpoints/proxy/dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ‎endpoints/restful/dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ‎ext-types/dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ‎globals/dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ‎lib/object-plus/events.d.ts

+9-8
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ export declare type Property = PropertyDescriptor | (() => any);
1414
export interface MessengersByCid {
1515
[cid: string]: Messenger;
1616
}
17-
export declare type CallbacksByEvents = {
18-
[events: string]: Function;
17+
export declare type EventCallbacks<Context> = {
18+
[events: string]: EventCallback<Context>;
1919
};
20+
export declare type EventCallback<Context> = (this: Context, ...args: any[]) => void;
2021
export declare class Messenger implements Mixable, EventSource {
2122
static __super__: object;
2223
static mixins: MixinsState;
@@ -30,13 +31,13 @@ export declare class Messenger implements Mixable, EventSource {
3031
_localEvents: EventMap;
3132
constructor();
3233
initialize(): void;
33-
on(events: string | CallbacksByEvents, callback: any, context?: any): this;
34-
once(events: string | CallbacksByEvents, callback: any, context?: any): this;
35-
off(events?: string | CallbacksByEvents, callback?: any, context?: any): this;
34+
on(events: string | EventCallbacks<this>, callback?: any, context?: any): this;
35+
once(events: string | EventCallbacks<this>, callback?: any, context?: any): this;
36+
off(events?: string | EventCallbacks<this>, callback?: any, context?: any): this;
3637
trigger(name: string, a?: any, b?: any, c?: any, d?: any, e?: any): this;
37-
listenTo(source: Messenger, a: string | CallbacksByEvents, b?: Function): this;
38-
listenToOnce(source: Messenger, a: string | CallbacksByEvents, b?: Function): this;
39-
stopListening(a_source?: Messenger, a?: string | CallbacksByEvents, b?: Function): this;
38+
listenTo(source: Messenger, a: string | EventCallbacks<this>, b?: Function): this;
39+
listenToOnce(source: Messenger, a: string | EventCallbacks<this>, b?: Function): this;
40+
stopListening(a_source?: Messenger, a?: string | EventCallbacks<this>, b?: Function): this;
4041
_disposed: boolean;
4142
dispose(): void;
4243
}

Diff for: ‎lib/object-plus/events.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ‎lib/transactions.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ‎package.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "type-r",
3-
"version": "3.0.3",
3+
"version": "3.0.5",
44
"description": "Serializable, validated, and observable data layer for modern JS applications",
55
"main": "./dist/index.js",
66
"jsnext:main": "./lib/index.js",
@@ -18,8 +18,9 @@
1818
"test": "tests"
1919
},
2020
"scripts": {
21-
"build:lib": "npm run compile:lib && npm run bundle:lib",
22-
"compile:lib": "rm -rf ./lib && node_modules/.bin/tsc",
21+
"build:lib": "yarn compile:lib && yarn bundle:lib",
22+
"build:cleanup":"node_modules/.bin/rimraf ./lib",
23+
"compile:lib": "yarn build:cleanup && ./node_modules/.bin/tsc",
2324
"bundle:lib": "node_modules/.bin/rollup --config",
2425
"test:backbone": "node_modules/.bin/qunit 'tests/backbone-regression/*.tst.js'",
2526
"test:type-r": "node_modules/.bin/jest",
@@ -80,7 +81,8 @@
8081
"sinon-chai": "*",
8182
"ts-jest": "*",
8283
"typescript": "*",
83-
"underscore": "*"
84+
"underscore": "*",
85+
"rimraf": "^2.6.3"
8486
},
8587
"dependencies": {
8688
"isomorphic-fetch": "*",

Diff for: ‎src/object-plus/events.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export interface MessengersByCid {
3434
}
3535

3636
/** @hidden */
37-
export type CallbacksByEvents = { [ events : string ] : Function }
37+
export type EventCallbacks<Context> = { [ events : string ] : EventCallback<Context> }
38+
export type EventCallback<Context> = ( this : Context, ...args : any[] ) => void
3839

3940
/*************************
4041
* Messenger is mixable class with capabilities of sending and receiving synchronous events.
@@ -93,21 +94,21 @@ export class Messenger implements Mixable, EventSource {
9394
/** Method is called at the end of the constructor */
9495
initialize() : void {}
9596

96-
on( events : string | CallbacksByEvents, callback, context? ) : this {
97+
on( events : string | EventCallbacks<this>, callback?, context? ) : this {
9798
if( typeof events === 'string' ) strings( on, this, events, callback, context );
9899
else for( let name in events ) strings( on, this, name, events[ name ], context || callback );
99100

100101
return this;
101102
}
102103

103-
once( events : string | CallbacksByEvents, callback, context? ) : this {
104+
once( events : string | EventCallbacks<this>, callback?, context? ) : this {
104105
if( typeof events === 'string' ) strings( once, this, events, callback, context );
105106
else for( let name in events ) strings( once, this, name, events[ name ], context || callback );
106107

107108
return this;
108109
}
109110

110-
off( events? : string | CallbacksByEvents, callback?, context? ) : this {
111+
off( events? : string | EventCallbacks<this>, callback?, context? ) : this {
111112
if( !events ) off( this, void 0, callback, context );
112113
else if( typeof events === 'string' ) strings( off, this, events, callback, context );
113114
else for( let name in events ) strings( off, this, name, events[ name ], context || callback );
@@ -126,7 +127,7 @@ export class Messenger implements Mixable, EventSource {
126127
return this;
127128
}
128129

129-
listenTo( source : Messenger, a : string | CallbacksByEvents, b? : Function ) : this {
130+
listenTo( source : Messenger, a : string | EventCallbacks<this>, b? : Function ) : this {
130131
if( source ){
131132
addReference( this, source );
132133
source.on( a, !b && typeof a === 'object' ? this : b, this );
@@ -135,7 +136,7 @@ export class Messenger implements Mixable, EventSource {
135136
return this;
136137
}
137138

138-
listenToOnce( source : Messenger, a : string | CallbacksByEvents, b? : Function ) : this {
139+
listenToOnce( source : Messenger, a : string | EventCallbacks<this>, b? : Function ) : this {
139140
if( source ){
140141
addReference( this, source );
141142
source.once( a, !b && typeof a === 'object' ? this : b, this );
@@ -144,7 +145,7 @@ export class Messenger implements Mixable, EventSource {
144145
return this;
145146
}
146147

147-
stopListening( a_source? : Messenger, a? : string | CallbacksByEvents, b? : Function ) : this {
148+
stopListening( a_source? : Messenger, a? : string | EventCallbacks<this>, b? : Function ) : this {
148149
const { _listeningTo } = this;
149150
if( _listeningTo ){
150151
const removeAll = !( a || b ),

Diff for: ‎src/transactions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { abortIO, IOEndpoint, IONode, IOPromise } from './io-tools';
2-
import { CallbacksByEvents, define, definitions, eventsApi, Logger, LogLevel, Messenger, MessengerDefinition, MessengersByCid, mixinRules, mixins, MixinsState, throwingLogger } from './object-plus';
2+
import { EventCallbacks, define, definitions, eventsApi, Logger, LogLevel, Messenger, MessengerDefinition, MessengersByCid, mixinRules, mixins, MixinsState, throwingLogger } from './object-plus';
33
import { resolveReference, Traversable } from './traversable';
44
import { ChildrenErrors, Validatable, ValidationError } from './validation';
55

Diff for: ‎yarn.lock

+8-1
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,7 @@ glob-parent@^2.0.0:
13381338
dependencies:
13391339
is-glob "^2.0.0"
13401340

1341-
glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2:
1341+
glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3:
13421342
version "7.1.3"
13431343
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.3.tgz#3960832d3f1574108342dafd3a67b332c0969df1"
13441344
integrity sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==
@@ -3355,6 +3355,13 @@ rimraf@^2.5.4, rimraf@^2.6.1:
33553355
dependencies:
33563356
glob "^7.0.5"
33573357

3358+
rimraf@^2.6.3:
3359+
version "2.6.3"
3360+
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab"
3361+
integrity sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==
3362+
dependencies:
3363+
glob "^7.1.3"
3364+
33583365
rollup-plugin-commonjs@*:
33593366
version "9.2.0"
33603367
resolved "https://registry.yarnpkg.com/rollup-plugin-commonjs/-/rollup-plugin-commonjs-9.2.0.tgz#4604e25069e0c78a09e08faa95dc32dec27f7c89"

0 commit comments

Comments
 (0)
Please sign in to comment.