Hamsters.js
  • Home
  • About
  • Services
  • Examples
    • Square Root
    • Collatz Conjecture
  • Wiki
  • Donate
  • Contact

Hamsters.js Wiki

  • Installing Hamsters

    • HTML
    • React Native
    • Node.js
  • Using Hamsters

    • Initializing
    • The Basics
    • Restructuring Standard Functions
    • Promises
    • Sorting
    • Persistence
    • Transferable Objects
    • Debugging
    • Limitations

Promises

Hamsters.js also supports the use of promises using a method called hamsters.promise, the traditional method hamsters.run makes use of callbacks. Promises can give you more sequential control of your application.

            
              var params = {
                array: [1, 2, 3, 4]
              };
              hamsters.promise(params, function() {
                for(var i = 0; i < params.array; i++) {
                  rtn.data.push(params.array[i] * 4);
                }
              }).then(function(results) {
                  console.log(results);
              }).catch(function(error) {
                  console.error(error);
              });
            
          

This should enable the use of async await as well giving you the power to take the above example and make it even easier.

            
              var params = {
                array: [1, 2, 3, 4];
              };
              var results = await hamsters.promise(params, functionToRun);
            
          

Recent Updates

New React Native Hamsters Release v1.0.9!

New Hamsters.js Release v5.4.1!

New Hamsters.js Release v5.4.0!

New Hamsters.js Release v5.3.9!

Subscribe To Updates

Register your email address to receive updates from the news letter such as new version releases, and terms of service changes.

© 2015 - 2024 asmithdev | All rights reserved.
  • Home
  • About
  • Privacy
  • License