Plugin Development: Is it possible to access a property on initialisation?

I’m trying to create a simple(ish) plugin to dynamically display how long ago something (a post, a comment etc) was created. You can do current date/time minus the created date, I know, but I’m using momemnt.js which does a better job of displaying text like ‘just now’, ‘5 seconds ago’ etc. I have done most of the difficult bits - actually getting it to calculate and display the time difference from now, for a dynamic date that the user (bubble developer) sets as a property.

My issue however is that using the update function, I can display the current value of the plugin when something changes, e.g. a new comment is created, but I also want this to happen for existing comments when for example the comments page or list is displayed. It seems however that I can not refer to a property in the initialize function. Is there a way to do this?

I could create a dynamic date action field I suppose, and have the user set it in a workflow action on page load, but that would mean the user (bubble developer) setting the property twice, once in the workflow and once in the property window. I’m hoping to avoid this.

I’m new to JS so probably just down to my lack of knowledge. I’m sure I’m missing something obvious. Any guidance would be much appreciated.

If the property is from a field, then no, you have to use this in update. But you can use the instance.data object to save some times.

Not sure that answers your question though…

Thanks @emmanuel. You say “If the property is from a field…”. Can I ask, as opposed to what?

As I understand it, instance.data would let me set the property in code. This is not my intention here, at least I don’t think it is. What I want to do is to retrieve the property (from a field), use it to do a calculation and publish the result as a state, and I was hoping to do all of this as part of the initialisation of my plugin. I think I understand though, why the property can’t be accessed until the plugin is fully initialised.

Yeah, a property would always come from a user defined field in the Propety Editor.

My solution was to have a one line initialize routine

instance.data.initialized=false;

Then I check that and do all my component initialization in the first call of update.

Some systems have a “post-initialized” callback. If bubbble created one that got the same parameters as update, this would all be cleaner.