iframe.io 0.0.10 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -32,9 +32,9 @@ export default class IOF {
32
32
  initiate(contentWindow: MessageEventSource, iframeOrigin: string): this;
33
33
  listen(hostOrigin?: string): this;
34
34
  fire(_event: string, payload?: MessageData['payload'], callback?: boolean): void;
35
- emit(_event: string, payload?: MessageData['payload'], fn?: Listener): this;
35
+ emit(_event: string, payload?: MessageData['payload'], fn?: CallbackFunction): this;
36
36
  on(_event: string, fn: Listener): this;
37
37
  once(_event: string, fn: Listener): this;
38
- off(_event: string, fn: Listener): this;
39
- removeListeners(fn: Listener): this;
38
+ off(_event: string, fn?: Listener): this;
39
+ removeListeners(fn?: Listener): this;
40
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iframe.io",
3
- "version": "0.0.10",
3
+ "version": "1.0.1",
4
4
  "description": "Easy and friendly API to connect and interact between content window and its containing iframe",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
package/src/index.ts CHANGED
@@ -165,7 +165,7 @@ export default class IOF {
165
165
  listeners.map( fn => payload ? fn( payload, callbackFn ) : fn( callbackFn ) )
166
166
  }
167
167
 
168
- emit( _event: string, payload?: MessageData['payload'], fn?: Listener ){
168
+ emit( _event: string, payload?: MessageData['payload'], fn?: CallbackFunction ){
169
169
 
170
170
  if( !this.peer.source )
171
171
  throw new Error('No Connection initiated')
@@ -178,7 +178,7 @@ export default class IOF {
178
178
  // Acknowledge/callback event listener
179
179
  let hasCallback = false
180
180
  if( typeof fn === 'function' ){
181
- const callbackFunction = fn as CallbackFunction
181
+ const callbackFunction = fn
182
182
 
183
183
  this.once( _event +'--@callback', ({ error, args }) => callbackFunction( error, ...args ) )
184
184
  hasCallback = true
@@ -209,7 +209,7 @@ export default class IOF {
209
209
  return this
210
210
  }
211
211
 
212
- off( _event: string, fn: Listener ){
212
+ off( _event: string, fn?: Listener ){
213
213
  // Remove Event listener
214
214
  delete this.Events[ _event ]
215
215
  typeof fn == 'function' && fn()
@@ -218,7 +218,7 @@ export default class IOF {
218
218
  return this
219
219
  }
220
220
 
221
- removeListeners( fn: Listener ){
221
+ removeListeners( fn?: Listener ){
222
222
  // Clear all event listeners
223
223
  this.Events = {}
224
224
  typeof fn == 'function' && fn()