How to override methods on Bokeh? How to check if

2019-07-14 12:01发布

I am running bokeh as a Bokeh Server Application.

I would like to do some actions when all the items are already rendered on the page. So I found that a message is printed in this file. How could I run some code after the message? Is there any flag that I could see to check if the server is loaded and all the elements rendered? Is possible to override methods on bokeh?

if promise != null
  promise.then(
    (value) ->
      console.log("Bokeh items were rendered successfully")
    (error) ->
      console.log("Error rendering Bokeh items ", error)
  )

Update

As this is still not possible, I found a workaround in the mean time:

oldLog = console.log;
console.log = function (message) {
    if(message.localeCompare('Bokeh items were rendered successfully') == 0){
        window.top.postMessage('show-bokeh-iframe', '*')
        console.log = oldLog;
    }
    oldLog.apply(console, arguments);
};

1条回答
smile是对你的礼貌
2楼-- · 2019-07-14 12:54

Currently there is nothing built into Bokeh for this. There is an open feature to add support for a user-hook to run code on a Bokeh document init:

https://github.com/bokeh/bokeh/issues/4272

This will hopefully be able to make it into 0.12.6.

My guess is that there is some way to do this with hacky JS, maybe someone else will have a workaround in the mean time.

查看更多
登录 后发表回答