Recognize removal of Widget in Cockpit Dashboard on Cumulocity - plugins

Is there a way (maybe an event or something we can subscribe to) to acknowledge inside a self implemented widget, whenever this or another widget is removed from the dashboard?

There is nothing like an event you can subscribe to.
In the end there will always be a PUT request to update the dashboard object whenever it changes. Maybe you can utilize that.

Related

Flutter reset all provider states after sign out

Whenever I sign out of my app, it seems to not clear all provider states and when I log in to another user my app crashes. Is there way to reset everything to default when performing logout action?
It depends on the scope of your provided objects. If you provide them at top level, the instances will not be disposed and live on.
Possible solutions could be:
Provide your state further down in the widget tree.
Observe a logout event in your state and perform reset of state automatically. There are multiple ways to do this, e.g. use a ProxyProvider.
ProxyProvider<Session, SomeStateClass>(
create: (_) => SomeStateClass(),
update: (_, session, instanceOfStateClass) {
return instanceOfStateClass..reinitialize(session);
}),
In the example above, the update method gets called, when Session notifies about changes.

Thunderbird78+: How to check for message create, reply and forward

I am a beginner in thunderbird addons so I really appreciate if you can help me. I am trying to find a way in my background javascript to check whenever a user has opened the window for create a new message, reply a message and forward a message. I want to put a default text in the message window before the user is gonna send it. I know thunderbird 78+ should only uses web extension APIs and i found this Compose API but how to use it in my background script.
https://thunderbird-webextensions.readthedocs.io/en/78/compose.html
It looks like setComposeDetails() is what you want.
setComposeDetails(tabId, details)
Updates the compose window. Specify only fields that you want to change. Currently only the to/cc/bcc/replyTo/followupTo/newsgroups fields and the subject are implemented.
tabId (integer)
details (ComposeDetails)
I have note tried it, but I suppose that either details.body or details.plainTextBody from the ComposeDetails object can be used to pass the default text you want to use. So I would try something like this in the background script:
let details = {
body: "This is my default text",
};
browser.messages.setComposeDetails(tabId, details);
You might have to combine it with a call to messages.getComposeDetails() if empty fields in details reset the values in the composer window (I don't know).
If you want to call this when the user opens a new compose window, I would look at the window.onCreated event. If you want to do it right before the message is sent instead, you should look at the compose.onBeforeSend event. All of them are described in the API documentation.

Flutter cookbook for widget that gets its state from a REST API and refreshes automatically?

What is the basic cookbook for a flutter widget that does this?
1) Displays initial state like "loading".
2) Async gets content from a REST API.
3) Updates state when the REST API returns success.
4) Refreshes content on a timer.
You may want to take a look here.
Generally speaking, you will have a StatefulWidget that calls the API on it's initState and store the "future" (async action in Dart) locally.
Then use FutureBuilder to know weither or not the data is loading/fetched/error. And display something accordingly.

Why my actions on Google doesn't recognize touch selection?

I'm writing a simple action on google without any webhooks. Every response is generated by dialogflow.
I have an intent that works flawless if I call it by speech or type but if I call it by selecting it from a list it doesn't work and the Default Fallback is called.
In the simulator it show the right "text" when I click on the list.
Have I done something wrong or did I need to specify something in the list?
This is how the list is generated
This is my intent
This is what happens in the simulator if I click on the "easyTravel" item in the list (it trigger the default fallback intent)
This is what happens in the simulator if I type "easyTravel" (the right intent is executed)
To catch a click on a list I need an intent configured to be triggered by the event actions_intent_OPTION
Only once I read this question - and your anwser - I could fix my own problem. Just to share: if you are using a webhook and are waiting for a webhook actions in your script, you can create a new intent, which has the event as #Edo states: actions_intent_OPTION. If you define an action in that intent, this is what will be trigger by your webhook. You can then get the parameter by (node.js):
const param = app.getSelectedOption();
Without the 'empty' intent, with the event and action, I was not receiving any input.

How to prevent code to execute after firing of history token in gwt?

I am working on gwt2.3 application with gwtp framework.In this application I am have one login (index) page which is bind by the client module.
bindConstant().annotatedWith(DefaultPlace.class).to(NameTokens.login);
Now after successfull login a new name token name user page is fired.
History.newItem(NameTokens.userconsole,true);
Now I have my history handler like below:
public class NameTokenHandler implements ValueChangeHandler {
#Override
public void onValueChange(final ValueChangeEvent<String> event) {
System.out.println("Nothing to do");
}
}
And I added to History like below in entry point class:
History.addValueChangeHandler(new NameTokenHandler());
Now as I have overridden the onValueChange method & I have left it blank.
So when application loads first or any other name token fires it should invoke onValueChange first
and as there no code in this method nothing should be load.
But in application it is working fine. All the name tokens are firing successfully even after there is no code in onValueChange. I am not getting how to prevent the firing of history token?
Please help me out.
Thanks in advance.
So when application loads first or any other name token fires it should invoke onValueChange first and as there no code in this method nothing should be load.
If you are using gwtp History ValueChangeHandler will not prevent or enable navigation to a particualr part of your application. That is all handled with PlaceManager.
After some googling I came to know about place manager.
I am adding_ a change handler to History. All the change handlers that
have been added already are still there. In particular, the one in GWTP's
PlaceManagerImpl constructor.
If you really want to prevent some history events from being handled by
GWTP, I would suggest that, in your custom PlaceManager, you
override onValueChange(...), intercept the tokens you want to block, and
call the parent's onValueChange for the tokens you want GWTP to handle
normally.