cay you try,

    setTimeout(function (){
        cb(moment().subtract(29, 'days'), moment());
     }, 3000);


On Tue, Mar 8, 2016 at 9:32 AM, Damith Wickramasinghe <dami...@wso2.com>
wrote:

> Hi,
>
> I have a requirement of  publishing data on load of publisher gadget. I
> have following script
>
> $(function () {
>
>     var TOPIC = "publisher";
>
>     var count = 1;
>
>     cb(moment().subtract(29, 'days'), moment());
>
>     function cb(start, end) {
>         if (count != 0) {
>             var message = {
>                 timeFrom: new Date(start).getTime(),
>                 timeTo: new Date(end).getTime()
>             };
>             console.log(message);
>             gadgets.Hub.publish(TOPIC, message);
>         }
>         count++;
>     }
>
> });
>
>
> As you can see I'm calling cb(moment().subtract(29, 'days'), moment());
> which will publish that data. If I comment above line and call the function
> when a button click then publisher works. It seems publisher functionality
> is not available or gadget is not properly loaded if we call as above. Am I
> missing something here ? or is there a better way to achieve this ?
>
> Thanks,
> Damith.
>
>
> --
> Software Engineer
> WSO2 Inc.; http://wso2.com
> <http://www.google.com/url?q=http%3A%2F%2Fwso2.com&sa=D&sntz=1&usg=AFQjCNEZvyc0uMD1HhBaEGCBxs6e9fBObg>
> lean.enterprise.middleware
>
> mobile: *+94728671315 <%2B94728671315>*
>
>
> _______________________________________________
> Dev mailing list
> Dev@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
Regards,
UdaraR
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to