Posts

javascript - Promise - is it possible to force cancel a promise -

i use es6 promises manage of network data retrieval , there situations need force cancel them. basically scenario such have type-ahead search on ui request delegated backend has carry out search based on partial input. while network request (#1) may take little bit of time, user continues type triggers backend call (#2) here #2 naturally takes precedence on #1 cancel promise wrapping request #1. have cache of promises in data layer can theoretically retrieve attempting submit promise #2. but how cancel promise #1 once retrieve cache? could suggest approach? no. can't yet. es6 promises not support cancellation yet . it's on way, , design lot of people worked hard on. sound cancellation semantics hard right , work in progress. there interesting debates on "fetch" repo, on esdiscuss , on several other repos on gh i'd patient if you. but, but, but.. cancellation important! it is, reality of matter cancellation really important scenario in...

How to add a logout callback for facebook sdk in android -

i have integrated facebook sdk in android app. described in manual added login callback facebook. have change ui if user logs out facebook. put code. code login /** * login callback facebook login */ callbackmanager = callbackmanager.factory.create(); loginmanager.getinstance().registercallback(callbackmanager, new facebookcallback<loginresult>() { @override public void onsuccess(loginresult loginresult) { //call updateui() setdata("provider","facebook"); logintype = logintypes.fb_login; isloggedin = true; graphrequest request = graphrequest.newmerequest( loginresult.getaccesstoken(), new graphrequest.graphjsonobjectcallback() { @override public void onc...

javascript - How can I get coverage of protractor with cucumber -

my project build on django , angular. use protractor cucumber , chai e2e test. , using "grunt-protractor-coverage" report code coverage. have question here if use jasmine protractor framework, when run "grunt test" it's fine. when use cucumber, error happens. [launcher] process exited error code 1 /users/paizanmay/documents/ichef/superadmin2.0/node_modules/protractor/node_modules/q/q.js:126 throw e; ^ error: spec patterns did not match files. @ runner.run (/users/paizanmay/documents/ichef/superadmin2.0/node_modules/protractor/lib/runner.js:249:11) @ taskrunner.run (/users/paizanmay/documents/ichef/superadmin2.0/node_modules/protractor/lib/taskrunner.js:123:19) @ createnexttaskrunner (/users/paizanmay/documents/ichef/superadmin2.0/node_modules/protractor/lib/launcher.js:220:20) @ /users/paizanmay/documents/ichef/superadmin2.0/node_modules/protractor/lib/launcher.js:243:7 @ _fulfilled (/use...

gulp - browser-sync is blocked by chrome csp -

i have gulp task runs browsersync. var options = { proxy : 'localhost:9000/html' , port : 3000 , files : [ config.root + config.srcpaths.htmlbundle , config.htmlroot + 'main.css' , '!' + config.htmlroot + '**/*.scss' ] , injectchanges : false , logfilechanges : true , logprefix : 'brosersync ->' , notify : true , reloaddelay : 1000 }; browsersync( options ); browsersync detects changes , tries inject them chrome blocks error: refused connect 'ws://localhost:3000/browser-sync/socket.io/?eio=3&transport=websocket&sid=goqqpsac3rbjd2onaaaa' because violates following content security policy directive: "default-src 'self'". note 'connect-src' not explicitly set, 'default-src' used fallback. uncaught securityerror: fa...

error handling - What is the right way to capture panics? -

frequently don't want our program stopping due out of bounds, division 0 or similar panics. however, std::thread::catch_panic marked unstable. write... let result = thread::scoped(move || { make_a_division_for_ever() }).join(); if result.is_ok() { println!("finished ok"); } is right way capture panics (like division 0 or out of bounds)? a complete example... use std::thread::thread; fn main() { println!("make divisions ever"); loop { let result = thread::scoped(move || { make_a_division_for_ever() }).join(); if result.is_ok() { println!("finished ok"); } else { println!("it crashed!!! restarting..."); } } } fn make_a_division_for_ever() { loop { println!("enter divisor..."); let line = std::io::stdin() .read_line() .ok() .expe...

java - How do static methods run? -

how static methods run in java? invoke them using class name, , not create object them, these objects can "run", not methods! in case of static method java loads method when class loaded , shares method objects , that's why object not necessary. it's not necessary have object in order run method. and no, it's not object runs. it's method operation , objects or classes hold them property.

C# Write Json file error -

i want write data object json file. my class person public class person { private string firstname; private string lastname; private int height; private double weight; public person() { } public person(string firstname, string lastname, int height, double weight) { this.firstname = firstname; this.lastname = lastname; this.height = height; this.weight = weight; } } my program class class program { static void main(string[] args) { // serialize json string , write string file person ps1 = new person("tay", "son", 180, 99.99); string json = jsonconvert.serializeobject(ps1,formatting.indented); file.writealltext(@"c:\person.json", json); console.writeline("done"); console.readline(); } } person.json displays: "{}" please helps me fix error. change code to: public string firstname; public st...