Issue I need to get an inserted object immediately after insertion has been done. But this is a problem with Angularjs $resource. module.factory(‘SearchQueries’, function($resource){ return $resource(‘/instances/searches/:_id’, {_id: ‘@id’}); }); var new_search = new SearchQueries({query: query}); new_search.$save(function(new_query){ console.log(new_query); console.log(new_query.id, new_query.query); console.log(new_query.$get());
Continue readingTag: callback
Markdown syntax highlighting in Javascript
Issue I am trying to get the rainbow syntax highlighting library to work with the marked markdown rendering engine. The marked documentation states that a syntax highlighter is supported through the following configuration option: marked.setOptions({ highlight: function(code, lang) { return
Continue readingngClass not updating after condition is changed in a callback
Issue I am trying to add a ‘loading’ class to an element until an asynchronous call is finished. To do so, I am using a variable named loading that I use like so: <div class=’ui segment’ ng-class=”{‘loading’: loading == true}”>
Continue readingJavaScript Scoping – Passing callback to already defined function
Issue The title is a bit weird, don’t quite know the best way to explain it in a sentence… At present there is an object with 3 functions; func, funcSuccess, and funcFailure. func contains a jQuery ajax request, with this.funcSuccess
Continue readingScoping issue when attempting to call CoffeeScript method inside Fancybox callback
Issue I have the following CoffeeScript module named Course. I have a small piece of code which I would like to re-use, I have created a method called preSelectItemSize. I would like to call this method when init is called
Continue readingPass a block variable to a callback function that has already arguments
Issue This is my callback: function evaluateServiceResponse(err, response){ db.answerCollection.insert({id: response[“serviceAnswer”][“id”]}); //problem is this line } This is my callback-user: mysoapclient.invokeServiceMethod(jsonRecords,this.evaluateServiceResponse); Here is the whole code. Inside process I create a block reference to my database: process(function(){ … let db=null; db
Continue readingFuture Proof Scoping In Callback Closures [Python]
Issue We’re generally familiar with this “gotcha” in Python due to it’s scoping: functions = [] for i in range(3): functions.append(lambda : i) out = [f() for f in functions] # naive expectation = [0, 1, 2] # actual result
Continue readingAlert in Meteor Angular 2 app only appears after click in browser
Issue I’ve implemented the ng2-bootstrap ngb-alert on a page of a Meteor Angular 2 app. When I push an alert to the alerts array in typescript, the alert is only displayed after i click the browser window again. The push
Continue readingAngularJS Typeahead callback function
Issue I know there is something wrong related to this callback function. But I’m not sure what is the best way to fix this. I have a resource: .factory(“AutoCompleteResource”, function ($http) { return { getAutoComplete: function (searchTerm) { $http.get(‘/cdeCompletion/’ +
Continue readingasync js callback for each upload
Issue I’m new at web develop. I was faced with the following problem: I upload images at amazon s3 and getting callback with response which contains link to this image. Then I push it into array and store this array
Continue readingHow to do an action after callback in node?
Issue How to fire the final console.log AFTER the callback is finished. var nodePandoc = require(‘node-pandoc’); var src, args; src = ‘Lesson.docx’; args = ‘-f docx -t markdown -o ./Lesson.md’; callback = function (err, result) { if (err) console.error(‘Oh No:
Continue readingtypescript callback with generic function
Issue I have the following code: type callbackType = <T>(d: T) => void; const callbackTest = <T>(val: T, callback: callbackType) => { callback(val); }; callbackTest("Hey", isAString => isAString) Here I would expect Typescript to deduce that isAString has the type
Continue readingConvert Callback to Promise in Publish Subscribe Model
Issue Let say we have a service called A and it has the function subscribe(callback). The subscription from the service is an open connection that can receive data at any time, and the data can be accessed through the callback.
Continue readingNode.js readline inside of promises
Issue I’m trying to use the node.js package readline to get user input on the command line, and I want to pipe the entered input through promises. However, the input never gets through the then chain. I think the problem
Continue readingbutton not triggering call back function when clicked on. No way to know why as no error's thrown by console
Issue I’m using an event listener on the button element. The user’s first asked to select a language. Once they’ve have done so they are presented with the button in question. Clicking on it triggers a call back function, enabling
Continue readingCan I mix callbacks and async/await patterns in NodeJS?
Issue I looked up for an answer on the internet but I could not really find what I was looking for. I need to know what is wrong with the following code (provided we should avoid mixing callbacks and promises)
Continue readingHow to integrate promises into a callback-based project?
Issue I’m working on a typescript project that is largely callback-based. Right now I’m working on a class and I had to write some new methods using other methods. So I promisified the methods I needed and wrote the methods
Continue readingHow to integrate promises into a callback-based project?
Issue I’m working on a typescript project that is largely callback-based. Right now I’m working on a class and I had to write some new methods using other methods. So I promisified the methods I needed and wrote the methods
Continue readingHow to return json from callback function within the Lambda?
Issue I’m trying to return the login status from the Cognito callback function, which is written in the NodeJS Lambda. However when I call the API the response keep loading and I’m getting warning error. Here is my code: ‘use
Continue readingNode.js readline inside of promises
Issue I’m trying to use the node.js package readline to get user input on the command line, and I want to pipe the entered input through promises. However, the input never gets through the then chain. I think the problem
Continue readingNode.js: can you use asynchronous functions from within streams?
Issue Consider the following: var asyncFunction = function(data, callback) { doAsyncyThing(function(data){ // do some stuff return callback(err) }) } fs.createReadStream(‘eupmc_lite_metadata_2016_04_15.json’) .pipe(JSONstream.parse()) .on(‘data’, asyncFunction) // <- how to let asyncFunction complete before continuing How does the stream know when asyncFunction has
Continue readingNode.js: can you use asynchronous functions from within streams?
Issue Consider the following: var asyncFunction = function(data, callback) { doAsyncyThing(function(data){ // do some stuff return callback(err) }) } fs.createReadStream(‘eupmc_lite_metadata_2016_04_15.json’) .pipe(JSONstream.parse()) .on(‘data’, asyncFunction) // <- how to let asyncFunction complete before continuing How does the stream know when asyncFunction has
Continue readingJavascript – Change two function then/catch style into the async/await style
Issue I’m try to understand how .then() function can get two arguments like this. const promise = doSomething(); const promise2 = promise.then(successCallback, failureCallback); or const promise2 = doSomething().then(successCallback, failureCallback); but I want to convert two arguments .then() to async/await like
Continue readingWhere will this callback function be registered in Node.js and how does it behave?
Issue const add = (n1, n2, callback) => { setTimeout(() => { const sum = n1 + n2 callback(sum) },2000)} add(1, 4, (sum) => { console.log(sum) // Should print: 5 }) I know that the setTimeout function will be registered
Continue readingPassing class method as callback to another class in javascript
Issue I am trying to create a pop up menu (via a class) called from another class. After these inputs are filled in I want the input data to be processed by the object from which the pop up menu
Continue readingHow to access Angular component property from a Google Charts callback
Issue Using angular-google-charts (Angular 13.2), I need to create a TreeMap with a custom tooltip. The GoogleChartComponent has an options property named generateTooltip that takes a callback function. From that function, I need to access data that is a property
Continue readingHow to call a typescript function inside callback of a JavaScript
Issue I’m using javascript Google Maps component in Angular 5 frontend framework export class MapComponent implements OnInit { ngOnInit() { this.initializeGMap() } initializeGMap() { var myLatlng = new google.maps.LatLng(12,77); var mapOptions = { zoom: DEFAULT_MAP_ZOOM, center: myLatlng, scrollwheel: true, styles:
Continue readingNext callback function in angular 7
Issue As a beginner i was going through the difference between observables and promise, one says that once a subscriber is subscribed it can get a callback to its next method everytime data(Observable) is returned from the http request. I
Continue readingHow to handle multiple async tasks in angular.js?
Issue Working on a sandbox app to learn angular.js I have encountered the following pattern in several places in my code. I find myself having to query the mongoDB in a loop. As I understand it, each call happens in
Continue readingHow do I pass a callback function to a child component?
Issue I’m writing an Angular 9 app and I have this shared component to produce a select menu … export class SharedMenuComponent implements OnInit { items: Item[] = []; // Represents what is selected by default @Input(‘default_selected’) default_selected: number; @Input(‘value_change_callback’)
Continue readingIn Angular how do I define a "router" member field?
Issue For Angular 9, I have a parent component in which I want to pass a function to a child component. I want to pass the "onNavigate" function to the child component … import { Router, ActivatedRoute } from ‘@angular/router’;
Continue readingRetrieving a value in a function in Node.js
Issue I’m struggling with callbacks in Node.js. I simply want playerNumber to be set to the number of players in my collection of Players. The console.log works, but I can’t get the variable out of the function and into the
Continue readingCalling node-oracledb's createPool Method
Issue I am creating a RESTful API that uses Node.js and Express. My application uses an Oracle database so I installed the node-oracledb module from npm. I’ve looked through the documentation and viewed some of the samples presented in the
Continue readingHow to wait for node exec response?
Issue how can I use a callback tor a promise correctly to get the result from a node exec in the condole.log() function? import { exec } from ‘child_process’; const check = () => { exec(`…`, (err, stdout) => {
Continue reading