Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3226514
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:27:57+00:00 2026-05-17T16:27:57+00:00

I am basically quite sure this pattern must exist and possess a name… for

  • 0

I am basically quite sure this pattern must exist and possess a name… for now I will call it “gate pattern”…

Here it is:

In my webpage’s javascript, I have to trigger various asynchronous processes. Let’s not discuss how trully async js is, but anyway I have to trigger 2 or 3 AJAX calls, must be sure, the UI build-up has finished, and so on.

Only then, when all these processes have finished, I want to do run a certain function. And precisely once.

Example

1: cropStore loaded()
2: resizeEvent()
3: productStore loaded()

The Pattern:
At the end of every (sucessful) Ajax-load-callback, the end of the GUI construction routine, etc… I set a respective flag from false to true and call gatedAction()

onEvent( 'load',
{
   ....  // whatever has to happen in response to cropStored, resized, etc...
   // lastly:
   f1 = true; //resp f2, f3, ...
   gatedAction();
}

Gate will check the flags, return if any flag is still unset, only calling the target function, if all flags (or as I call them: gates) are open. If all my async pre-conditions call gatedAction() exactly once, I hope I can be sure, the actual targetFunction is called exactly once().

gatedAction ()
{
   // Gate
   if ( ! f1) return;
   if ( ! f2) return;
   if ( ! f3) return;

   // actual Action ( <=> f1==f2==f3==true )
   targetFunction();
}

In practice it works reliably. On a side-note: I think java-typical (not js-typical) synchronization/volatile concerns can be ignored, because javascript is not truly multithreading. Afaik a function is never stopped in the middle of it, just to grant another javascript function in the same document run-time…

So, anyone, is there a name for this? 🙂

I need this pattern actually quite often, especially with complex backend UIs.. (and yes, I think, I will turn the above butt-ugly implementation into a more reusable javascript… With a gates array and a target function.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:27:57+00:00Added an answer on May 17, 2026 at 4:27 pm

    It is similar to the Rendezvous pattern, although that pattern is generally used in the context of multithreaded real-time systems.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, something better than this: <input type=file name=myfile size=50> First of all, the browse
I'm not quite sure how to describe this in words without making it overly
Basically what I want to do it this: a pdb file contains a location
Basically I'm going to go a bit broad here and ask a few questions
Basically I am trying to restart a service from a php web page. Here
Basically I’ve heard that certain conditions will cause .NET to blow past the finally
I ran into this quite often stated problem but even after looking up nearly
I guess I'm not quite sure how the Linq inheritance is supposed to work.
I'm very new to web technologies and this is basically for a term project
I'm not all that familiar with jquery so I'm not quite sure how to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.