JoshDSommer / nativescript-slides

A NativeScript plugin that is for Intro Tutorials, Image Carousels or any other slide functionality
Other
70 stars 32 forks source link

Feature Request: Slide Change Event #29

Closed shripalsoni04 closed 8 years ago

shripalsoni04 commented 8 years ago

I think currently we don't have any way to know when slide is changed. It will be very good if we have an event whenever slide is changed to satisfy scenarios like changing state of some controls, which are not inside slide, depending on active slide.

After having a quick look at code, I think we can call notifyat the end of setupPanel method like this:

private setupPanel(panel: ISlideMap) {
    ...
    this.setActivePageIndicator(this.currentPanel.index);
    this.notify({
        eventName: 'slideChanged',
        object: new Observable({currentPanel: this.currentPanel})
    });
}

What do you think?

JoshDSommer commented 8 years ago

@shripalsoni04 I was looking into this, I'm not familiar with the notify function, but do we need the object to be an observable or can it just be the currentPanel object?

shripalsoni04 commented 8 years ago

Notify function is used to emit custom events. As per the documentation of custom events, notify method takes the implementor of EventData Interface as an argument. This EventData Interface only accepts observable as the object value.

Though I have tried to send a plain object as an object value in notify function, it is also working properly without any issue.

But, I think we should send observable as object value in notify method so that any future change in event mechanism of nativescript do not break this.

JoshDSommer commented 8 years ago

Hi @shripalsoni04 @sitefinitysteve end up adding these going above and beyond and adding a couple other events. It's merged now and I should have it published to npm this evening. :+1:

JoshDSommer commented 8 years ago

https://github.com/TheOriginalJosh/nativescript-slides/pull/36