feedhenry / fh-js-sdk

FeedHenry Javascript SDK
http://feedhenry.org/fh-js-sdk/
Apache License 2.0
8 stars 37 forks source link

Add fh cloud is ready event #88

Closed okonon closed 10 years ago

okonon commented 10 years ago

Hello is it possible to emit 'fhcloudready' event like so: .... module.exports = { "boxprefix": "/box/srv/1.1/", "sdk_version": "2.0.3-alpha", "config_js": "fhconfig.json", "INIT_EVENT": "fhinit", "FH_READY_EVENT":"fhready" }; .... events.emit(constants.FH_READY_EVENT); logger.info("fh cloud is ready"); ... That way on you can listen to this like so: $fh.on('fhready',function(){ console.log('CLOUD IS READY EVENT EMITED'); });

Thanks a lot.

wei-lee commented 10 years ago

@softBarbarian fhinit event is in fact the cloud ready event. You can use it to listen for cloud ready event like this:

$fh.on('fhinit', function(err, hosts){
  //cloud is ready if err is null
})

Thanks.

okonon commented 10 years ago

Thanks a lot!

okonon commented 10 years ago

How do I wait for cordova.deviceready and then initialize fh sdk? Something like:

On(deviceready, function(){ &fh.init(fhconfig.json); On(fhready, func(){ do stuff }); });

wei-lee commented 10 years ago

well, you do not need to.The js sdk will init itself, and will emit the fhinit event when it is ready. You just need to listen on the deviceready event and initialise your app.

Wei Li On 13 Jun 2014 21:15, "softBarbarian" notifications@github.com wrote:

How do I wait for cordova.deviceready and then initialize fh sdk? Something like:

On(deviceready, function(){ &fh.init(fhconfig.json); On(fhready, func(){ do stuff }); });

— Reply to this email directly or view it on GitHub https://github.com/feedhenry/fh-js-sdk/issues/88#issuecomment-46055243.


This email message is from FeedHenry Ltd. The email and any files transmitted with it are confidential and may also be privileged and intended solely for the use of the individual or entity to whom they are addressed. Any unauthorized direct or indirect dissemination, distribution or copying of this message and any attachments is strictly prohibited. If you have received the email in error please notify postmaster@feedhenry.com.

FeedHenry Ltd., Cleaboy Business Park,Waterford, Ireland. Registered in Ireland as Company Reg. Number: 458931 www.feedhenry.com


okonon commented 10 years ago

Thanks for quick reply. The problem I am running into is that on android fh sdk units itself before device is available. That said, when fh sdk runs getDeviceId() it creates a mock uuid because window.device.uuid is undefined.

wei-lee commented 10 years ago

ok, I believe this is a bug. We are working on a fix for this now and will update the sdk as soon as the fix is available.

wei-lee commented 10 years ago

This issue is now fixed in branch 7449-init-on-deviceready. Will merge back to master once it's deployed. But you can download the file from the dist directory.

okonon commented 10 years ago

Awesome. Thanks a lot!

wei-lee commented 10 years ago

Merged back to master.