15,899,026 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by yno1 (Top 22 by date)
yno1
29-Sep-14 6:46am
View
when i say "asynchronous" i mean any function that needs to takes a callback as a parameter. I saw that this term is confusing you both so i decided to take it back.
someone deleted my discussion with peter (i'm guessing because we did not speak English) but he was able to understand me at least.
he gave as an example a sequence of many ajax call that should be handled sequentially. how would you do this?
I would put each call in a separate function, and each function ajax call in its turn will call the next function (=the next ajax call).
In short, I think that this solution is ugly and i want to solve this ugliness.
can you suggest a better solution?
yno1
29-Sep-14 5:29am
View
הדוגמה שלך של האג'קס (כשכותבים את המילה באנגלית זה מתבלגן) היא טובה, זה בדיוק הקושי שאני מנסה להתגבר עליו.
שהקוד נהיה מהר מאוד מגעיל כשחייבים שהקריאות יתבצעו בצורה סדרתית...
לא מצליח להבין מה ההבדל בין הדוגמה של אג'קס לבין הדוגמה שאני הבאתי אבל אם זה עוזר לך להבין אז סבבה, בוא נשאר עם רצף של 20 קריאות אג'קס שאנחנו רוצים שיתבצעו בצורה סדרתית.
ניסיתי לחשוב איך אפשר לפתור את זה במסגרת ספריה אבל אני לא מצליח...
זה מרגיש לי דווקא כמו פתרון שצריך לבוא מבפנים, מהאינטרפרטר עצמו.
יש לך רעיון?
דרך אגב אתה חושב שאם אני אציג לסרגיי את הבעיה כרצף של 20 קריאות אג'קס שצריכות
להתבצע בצורה סדרתית זה באמת יקל על ההבנה?
אני לא מצליח להבין מה ההבדל בין קריאת אג'קס לבין כל קריאה אחרת שדורשת שנעביר לה קולבק...
yno1
29-Sep-14 4:56am
View
אני חושב שמלכתחילה הבעיה שלי היתה שבכלל ציינתי את המילה
asynchronous...
בבקשה פשוט תתעלם ממנה וכנ"ל מהמילה
wait
שתיהן היו בחירות לא מוצלחות כנראה ונגעו בעצבים מעט חשופים כי ג'ווה-סקריפט רחוקה שנות אור משני המונחים הללו..
בפשטות מה שאני מדבר עליו זה מציאת פתרון אלגנטי למצב שבו יש בקוד שרשרת קולבקס.
אתה מבין למה זה בעייתי שצריך לכתוב 20 פונקציות שונות אם רוצים לכתוב תהליך שמבצע 20 קריאות שדורשות קולבק ותלויות אחת בשניה?
אם המשפט האחרון היה מבלבל אז פשוט תקח את הדוגמה של המפתח והשם ותדמיין שיש עוד 18 שלבים כאלה שתלויים אחד בשני
ההצעה המקורית שלי היא אכן קצת תלושה, והיא פחות הצעה ויותר ניסיון דחיפה לדיון בנושא...כי אני מאמין שזאת בעיה שרבים נתקלים בה ואולי בעזרת חשיבה קולקטיבית ניתן יהיה למצוא פתרון אלגנטי.
אתה מרגיש שעכשיו אתה מבין משהו שונה ממה שהבנת לראשונה כשקראת את הפוסט שלי?
כי אם כן אשמח אם תגיד לי מה בלבל אותך ואיך אני יכול לנסח את הדברים אחרת...
שנה טובה ומתוקה:)
yno1
29-Sep-14 4:10am
View
I really appreciate your intentions and your time. really. so first of all let me thank you for that.
But sadly, you still misunderstood me. I blame no one but my bad English and maybe i should have not use the term asynchronous in my question.
let us wait and see if some other users could understand my question and hopefully explain it better then me.
As a last resort i also tried to explain to Kornfeld Eliyahu Peter the situation in my mother tongue and if he understand me i hope he could clear the thing that i couldn't.
Thanks again for your time!
yno1
29-Sep-14 3:57am
View
תקשיב, גם ככה אף אחד לא יקרא כבר את העץ תגובות העצום הזה שלא מוביל לשום מקום אז תרשה לי לכתוב לך בעברית ואחר כך אני אמחק את התגובה הזאת..
אני כבר לא מצפה לתשובה, רק רוצה שתבין את כוונתי כדי לסגור פינות כי משום מה גם אתה וגם סרגיי פשוט לא מצליחים להבין למה אני מתכוון למרות שכששאלתי בפורום בעברית כולם הבינו ישר, אז אני מניח שהבעיה היא באנגלית שלי.
אז ככה:
בוא נניח לרגע שהבוס שלך מבקש ממך לכתוב פונקציה שמבצעת התחברות למערכת כלשהי. הפונקציה הזאת מבצעת קריאה ל-
getKey(value, callback), getName(value, callback).
אתה יודע שהקריאה לקבלת השם תלויה בערך של המפתח אז אתה צריך קודם לקרוא לקבלת מפתח ואז מעביר לה בקולבק פונקציה שתטפל בתורה בקבלת השם. בדיוק כמו בדוגמה שהבאתי לכם.
ומה אם יש לך 20 פעולות שתלויות אחת בשניה?
אתה תצטרך לפרק את הקוד ל-20 פונקציות.
בקיצור, אחרי שסיימת להתבאס מהעבודה שאתה צריך לכתוב עכשיו 20 פונקציות בשביל להתחבר למערכת, אתה מבין שאולי אתה יכול לבנות משהו שיעשה את זה אוטומטית...כמו שיש כלים שמפרמטים לך את הקוד למשל.
מה הכוונה? אתה כותב פונקציה אחת עם כל הקריאות שדורשות קולבק, והכלי שבנית יתקן את הקוד שלך ויפרק את הפונקציה הגדולה ל-20 פונקציות באופן אוטומטי....זה מאוד פשוט לבנות כלי כזה שיעשה לך את העבודה.
קיצר בנית את הכלי הזה וכולך מבסוט, ואז נופל לך האסימון- למה לעזאזל לא ללמד את האינטרפטר של ג'אווה סקריפט לעשות את זה בעצמו???
אני אכתוב לו קוד יפה והוא ידע בזמן אמת לקרוא את הקוד כאילו מדובר בשרשרת של קולבקס...
פה בדיוק נכנסת השאלה שלי.
מקווה שעכשיו זה ברור...
אני מבין את הבעיתיות של כתיבה בעברית, אבל הותשתי....אם לא ההודעה הזאת אז פשוט לא הייתי מגיב.
אם בכל זאת אתה מוצא שאחרי ההודעה הזאת אתה מבין את כוונתי, אני אמחק אותה ואני אשמח אם תסביר לי איך להסביר טוב יותר את השאלה שלי...אולי תערוך את את תשובתך.
ברגע שתגיב להודעה הזאת אני אדע שראית אותה ואני אמחק אותה.
yno1
28-Sep-14 18:20pm
View
you are still getting me wrong...
read my discussion with Kornfeld Eliyahu Peter. i think he starts to get me right
yno1
28-Sep-14 17:50pm
View
this is exactly what im saying! you need to add an event handler and put inside it the waiting code...just like i showed in my example.
but why doing it manually?
why not making the interpreter smart enough to do it by itself behind the scenes when he sees the word "wait"??
my proposal try to this using few stack pointer and existing mechanisms....
yno1
28-Sep-14 17:35pm
View
keypress, local storage, messaging to tabs...
in the current example, let us say that the getKey needs to wait for the data to be pulled from the local storage..
yno1
28-Sep-14 17:21pm
View
ok...now im getting your attention:)
i knew we have a definition problem.
when i say an asynchronous call i mean to every function that ask for a callback. why this function ask for a callback? probably because it needs to wait for an event.
lest say that getKey needs to wait for an event. what will we do?
we give it a callback so it returns to us when the event accrues.
but what if the rest of the code, like the call to getName, is meaningless before getKey got the event? we need to wait.
so we will put getName inside the callback...and so on.
please check the last example that i gave to sergey
yno1
28-Sep-14 17:12pm
View
i don't want to make things asynchronous.
i want to be able to wait for an event to happen without using a callback. we can call it an anonymous callback.
yno1
28-Sep-14 17:01pm
View
i still think that you misunderstood me.
im talking about the case when you need to force a synchronous structure onto a sequence of asynchronous calls..
the way to do this right now is to use a chained callbacks structure..
i want to suggest a syntactic sugar to solve the ugliness that this solution (the chained callbacks) introduces.
yno1
28-Sep-14 16:50pm
View
1. here is what i considered a nice function:
function foo(){
var result = "error";
var key=getKey();
if(verify(key)){
var name=getName();
if (verify(name)) {
login(key,name);
result = "ok";
}
}
return(result);
}
2. now if getKey and getName needed a callback, this function should be break into this:
function foo(){
getKey(callback);
}
function callback(key){
if verify(key){
getName(callback2);
}
function callback2(name){
if verify(name){
return "ok";
//....
}
}
you see how this simple "nice" method becomes ugly when callbacks are needed?
here is the same function, but lets say that we could introduce a new syntax that will do exactly the same as in (2), but will look like this:
function foo(){
var result = "error";
wait var key=getKey();
if(verify(key)){
wait var name=getName();
if (verify(name)) {
login(key,name);
result = "ok";
}
}
return(result);
}
yno1
28-Sep-14 16:45pm
View
i don't get it...
why isn't it asynchronous?
maybe we are just calling things differently?
if i told you that getKey needed to take a callback, cant you see how foo need to be changed to fit it?
יש דרך לשלוח הודעות פרטיות באתר? נראה לי שבעברית יהיה לי הרבה יותר קל:)
yno1
28-Sep-14 16:17pm
View
please read my clarification (i edited the original post).
you completely misunderstood my question:(
yno1
28-Sep-14 16:11pm
View
Deleted
please read my clarification (i edited the original post).
you completely misunderstood my question:(
yno1
28-Sep-14 16:04pm
View
what do you mean about that?
I know it's asynchronous because i'm making asynchronous calls!
ill give an example:
look at this code:
function foo(){
var result = "error";
var key=getKey();
if(verify(key)){
var name=getName();
if (verify(name)) {
login(key,name);
result = "ok";
}
}
return(result);
}
(sorry about the mass...i don't know how to insert code in the replay)
now im telling you that getKey() method is asynchronous and needed a callback...what will you do?
and what if i told you that get name is also async and needed a callback?
you see how this nice function is breaking into smaller functions that are chained using callbacks?
yno1
28-Sep-14 15:51pm
View
i think you didn't understood my intentions...
I'm trying to solve the problem using existing mechanisms so it will not introduce new complexity nor performance penalty.
I want to suggest a syntactic sugar solution for the callback mass.
how could we syntactically restructure the callbacks chain into a more elegant code?
There has to be a way...we just need to find it.
please try and read my question again but now think of it only as a syntactic sugar...not real change in the way JS works..
yno1
28-Sep-14 14:00pm
View
lol...and not in a brief?
yno1
16-Sep-14 11:55am
View
the innerListElement is defined in the upper scope as:
var innerListElement = document.createElement("LI");
that is...there is nothing to track of.
BTW im starting to think that my first Impression about the switching of the lines is not the cause of the problem...im thinking now that the problem is actually the console. is it possible?
it seems like only when the chrome console is open my tab crashes. but im not sure.
the only thing that i sure of is that the problematic line is innerListElement.appendChild(nameTile) but i don't know why sometimes it works and sometimes not.
yno1
16-Sep-14 11:46am
View
how does httpFox Intercepts the GET request? don't you see how absurd it is?? httpFox can give me exactly the string that i need, with all the images id's...if httpFox can do this, why cant i do it?
yno1
16-Sep-14 11:08am
View
i'm was play around with httpFox and i was able to find the GET request that the browser is using to display the request the images, but how can i find who prepared the request?
it seems like the request is dynamically prepared...is there a tool to find out things like that?
yno1
14-Sep-14 16:39pm
View
thank you very much!
i will try this HttpFox and play with it and see what i get and i will post an update soon!
Show More