Comments (6)
I can't reproduce this. Can you include your options for Redis and Rebridge - or alternatively, a minimal but complete example that errors?
I used this file, with Rebridge 2.3.0:
const Redis = require("redis");
const Rebridge = require("rebridge");
class KnifeBot {
constructor(config) {
this.redis = Redis.createClient(config.redisOptions);
this.db = new Rebridge(this.redis, config.rebridgeOptions);
}
pickGame() {
return "Hey";
}
setGame() {
let game = this.pickGame() // This line errors
console.log(game);
}
}
const bot = new KnifeBot({
redisOptions: {},
rebridgeOptions: {
mode: "deasync"
}
});
bot.setGame();
It works correctly by printing "Hey" to the console. It also works with mode: "promise"
and without any Rebridge options.
from rebridge.
Both of my options for Redis and Rebridge aren't defined in my current config file, so undefined
. Your example works fine for me, I'll create a stripped down version of my current implementation and see if it fails there.
from rebridge.
So it turns out that the this.pickGame is not a function
error was caused because I was missing a config option, for some stupid reason. However console.log
-ing still results in an error that points to Rebridge.
(It also seems that adding the console.log
stops the first error from happening. Somehow.)
I've made a repo here which reproduces the errors.
from rebridge.
Thank you, I'll work on it.
from rebridge.
Ah, spotted it! That's a problem with your code, that doesn't depend on the usage of Rebridge. Indeed, if you try to remove all usages of Rebridge, you'll see that it still errors.
The problem is on this line (events/ready.js:23
):
if (!bot.gameLoop) bot.gameLoop = setInterval(bot.setGame, bot.config.gameInterval);
What happens is that bot.setGame
will not be called on the bot
object, but on a Timeout
object (specifically, the one returned by setInterval
). This behaviour is documented here, and can be solved by using setTimeout(bot.setGame.bind(bot), ...)
or more elegantly with setTimeout(() => bot.setGame(), ...)
.
from rebridge.
Huh, that's pretty weird behaviour. Thanks a lot for your help anyway! :)
from rebridge.
Related Issues (9)
- Nice hack! HOT 2
- process._tickDomainCallback is not a function in Node >= 9.3 HOT 1
- About the delete function?
- An advice HOT 2
- Splicing a second-level array throws an error HOT 2
- Improve serialization/deserialization to add support for circular objects HOT 3
- Unexpected Token index.js HOT 3
- Rehydrating from running redis after nodejs restart HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rebridge.