Skip to content

Events.publish passes arguments as an array to subscriber #7314

@stalniy

Description

@stalniy

Short description of the problem:

Events.publish passes all arguments as first argument of subscriber :
https://github.com/driftyco/ionic/blob/master/src/util/events.ts#L99

What behavior are you expecting?

Arguments should be passed as arguments into subscriber

import { Events } from 'ionic-angular'

const events  = new Events()

events.subscribe('test', function(error) {
   // actual (all arguments passed as first argument of subscriber)
  console.log(error); // [Error(), 1]

  // expected  (all arguments passed as arguments of subscriber)
  console.log(error); // Error()
})

events.publish('test', new Error('test'), 1) 

Other information:
Basically https://github.com/driftyco/ionic/blob/master/src/util/events.ts#L99 line should be changed to:

responses.push(handler(...args));

Which Ionic Version? 1.x or 2.x
2.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions