I read in mozilla doc, Element.createShadowRoot() is deprecated:
This method has been deprecated in favor of attachShadow.
But in my canary: chrome 49.0.2599.0
thats work:
var shadow = document.getElementById("node-sh").createShadowRoot();
And thats not work
var shadow = document.getElementById("node-sh").attachShadow({mode: 'closed'});
Anyone know what's right?
createShadowRoot() is the old way of attaching a shadow-root to host element. It was proposed in initial spec, which has then been deprecated in favor of
attachShadow.
Spec also has been updated.
But, new API hasn't been standardized and none of the browsers currently support it. So I would suggest to stick to createShadowRootfor now. Once you start getting browser warnings for deprecation, that would be the time to move to attachShadow.
Related
I am trying to use the attributeService.getEntityAttributes function to obtain some server attributes of my device. I was using the .getEntityAttributesValues function when working with the 2.x version of Thingsboard and it was working fine. With the current version I am using the following code:
var conf = {
ignoreLoading: false,
ignoreErrors: true,
resendRequest: true
};
var myattr = attributeService.getEntityAttributes(entityID,'SERVER_SCOPE',["myattribute"],conf);
But I get no data or error back. I was using the .getEntityAttributesValues with .then() method but it doesn't seem to work anymore. It says ".then is not a function".
What am I doing wrong? Please help and tell me how to use the new function properly. I am using TB v.3.1.1 CE.
Thingsboard 2.x UI was made with AngularJS.
Thingsboard 3.x UI now uses Angular.
One of the key differences between these frameworks in regards of your problem is the move from Promise based services, to Observable based services.
Let's look at the source of the getEntityAttributes function:
https://github.com/thingsboard/thingsboard/blob/2488154d275bd8e6883baabba5519be78d6b088d/ui-ngx/src/app/core/http/attribute.service.ts
It's mostly a thin wrapper around a network call made with the http.get method from Angular.
Therefore, if we have a look at the official documentation: https://angular.io/guide/http#requesting-data-from-a-server, it is mentioned that we must subscribe to the observable in order to handle the response. So something along the lines of:
attributeService.getEntityAttributes(entityID,'SERVER_SCOPE',["myattribute"],conf).subscribe((attributes) => {…})
During my test on Pepper, I found some difficulties in realizing continuative collaborative dialog.
In particular, after about 10 minutes, it seems that the ALSpeechRecognition engine stops working.
In other words, Pepper dialog panel remains empty and/or the robot does not understand my words, even if the structure worked some minute before.
I tried to stop and restart it (i.e., the engine) via SSH terminal, by using:
qicli call ALSpeechRecognition.pause 1
qicli call ALSpeechRecognition.pause 0
It should restart the engine according to the guidelines shown here, but it does not work.
Thank you so much guys.
Sincerely,
Giovanni
According to the tutorial, starting and stopping the speech recognition engine is done by subscribing/unsubscribing it.
The recommended way to do this is unsubscribing and subscribing back to it. For me it also worked changing the speech reco language and chaging it back to the one you had previously.
Luis is right and to do so just create a function as below given and call it if ActiveListenning event comes false from ALSpeechRecognition module. Note: Use ALMemory module to get data from ALSpeechRecogntion.
asr_service = ALProxy("ALSpeechRecognition",ip,port)
memory = ALProxy("ALMemory",ip,port)
def reset():
asr_service.unsubscribe("ASR_Engine")
asr_service.subscribe("ASR_Engine")
ALS = memory.getData("ALSpeechRecognition/ActiveListening")
if ALS==False:
reset()
I am trying to create my composite LWM2M object by using objlink type.
For Leshan, the only source on how to write the spec file in JSON seems to be the official oma-objects-spec.json, which does not contain examples of objlinks.
Can anyone provide an example on how to create an objlink object?
If it is not possible in Leshan, have anyone tried other implementations?
Hope it's not too late.
As of now there is no support of OBJLNK in Leshan API.
I was also needed OBJLNK support in Leshan so i have modified and created a pull request for supporting OBJLNK.
If you want to have objlnk support can use my branch which is forked from Leshan.
https://github.com/DevendraKurre/leshan
Leshan has added support to this feature. I have tested it with version 0.1.11-M14.
Reading can be done as usual, and writing is done as follows.
WriteRequest writeReq = new WriteRequest(
WriteRequest.Mode.UPDATE,
9, 0,
LwM2mSingleResource.newObjectLinkResource(
13,
new ObjectLink(5566, 7788)
)
);
In a mozille extension I run:
SecSess.Logger.info("ctypes test");
Components.utils.import("resource://gre/modules/ctypes.jsm");
SecSess.Logger.info("1");
this.lib = ctypes.open("libcrypto.so");
SecSess.Logger.info("2");
var a = new Uint8Array(1<<10);
SecSess.Logger.info("3");
var ptr = new ctypes.uint8_t.ptr(a.buffer);
SecSess.Logger.info("4");
Why this ugly logging after each step you might ask? Well this code fails without showing me an error. (or at least I can't find the error message)
This is printed:
ctypes test
1
2
3
So the 5th log message is never printed which means the following statement never completes:
var ptr = new ctypes.uint8_t.ptr(a.buffer);
This is a simplified version of some old code I have to work with and which I also found online as being valid. However it doesn't work. This add-on wasn't developped using the new SDK with jpm. Quite frankly I don't know how and when it was developped but I need to run some tests on it. It comes with a few source files ordered in a components and a modules directory and a chrome.manifest and install.rdf in the root. I copied these files to the extension directory of Mozilla in order for it to work. The extension executes but there seems to be a problem with ctypes. Aren't ctypes fully supported anymore or are these old style add-on no longer valid for the modern Firefox?
Regards,
Roel
I think they landed a a patch to disallow making a pointer from buffers. I'll double check.
Edit:
Ah per this: https://developer.mozilla.org/en-US/docs/Mozilla/js-ctypes/Using_js-ctypes/Working_with_ArrayBuffers, you don't have to wrap it with a ctypes.uint8_t.ptr just pass it like a.buffer to wherever you need it. :)
I am using FBTweak lib in my iOS project. I wonder is there difference between FBTweakBind and FBTweakValue.
For example:
FBTweakBind(self.headerView, alpha, #"Main Screen", #"Header", #"Alpha", 0.85);
can rewrite like this:
self.headerView.alpha = FBTweakValue( #"Main Screen", #"Header", #"Alpha", 0.85 );
so are they just equal ?
I am playing with FBTweak lib only since couple of minutes, but from what I understood from the documentation on github, FBTweakValue is just setting the value, but FBTweakBind is binding the changes to make tweaks update live.
Keep in mind, that both FBTweakValue and FBTweakBind might behave differently in a release builds
Source: https://github.com/facebook/Tweaks/wiki#bind
I figure it out.
FBTweakBinding will refresh the value it's binding. It means that FBTweak will call the setter of the property whenever you change the value while app is running.
FBTweakValue is just a variable. When program is going through that line of code, the property will be set. If you change the FBTweakValue after where it used, it did nothing, unless that line of code running again.