The main use case I have for bindable functions is to communicate between 2 module scripts, without having a recursive requiring() thing happen. I have script A require(scriptB), then have scriptB use the remote function to call a function in script A. There may be other uses but this is the one I know of
Yes I agree that this would be an acceptable use of it, however using custom signals like FastSignal takes out the worries of having objects in the workspace and puts it into a code dependent state which is prefered in any practice of codebase management.
The moment you use BindableEvents, you must have a dependent instance created within your workspace, which puts risk of one place not having it or it deleting itself for whatever reason. That does not happen with modular code Signals.
It is also a good idea to apply a specific structure to prevent such recursion except if absolutely necessary. Using/Creating a Module importer allows one to import the module later on if necessary, and prevents that recursion.
The only way I would use BindableEvents is through the Reset button callback.
In that case, you can just have both modules require a “middleman” module to literally connect their environments. A and B requires C, rather than A and B requiring each other. You could also use SharedTables, even though that’s meant to be used for parallel code. Both of these options should be more performant than using bindables to transfer data, which is susceptible to bandwidth bottlenecks, deferred events, and any other problems related to instancing.
You mean remotes. Bindables can’t transfer data between server and client.
This would still produce issues should C module require loop back to A… Not to mention dependencies at the start of the module towards the recursed modules would produce many unpromised results.
The idea is that the middleman module is an empty “slave” table that doesn’t do anything on its own. It only read and write values to a table that is accessible by its masters. If it ever did have free will then it would fall under your solution of using a module importer
I see what you mean now! In the grand scheme of a codebase, I feel as if this would be quite an uncommon occurence and practice… but indeed it would produce the results. This should only be used as a last result as well
While I appreciate the debate and banter, no one has given a definitive answer. To clarify Bindable events and functions do not cross client server boundaries, that is remote events/functions . To communicate between scripts on the same side I have always used module scripts. I really want to know is there any situation where Bindable events / functions are a better solution or is using Bindables just an alternative?
In my beliefs, Bindable Events are already good enough to communicate between servers and transfer between data and processing whatever values instead of client’s interference. If you’re a person that’s obsessed with separating scripts (like me), and often struggles with Modules or Libraries a lot (and I heavily struggle on understanding the concept of it too), you would use Bindable Events. Let’s say you want to transfer data of player coins from DataStore Script to script where it processes purchase and then initiate another event which confirms and returns the post-purchase value of coins. In my personal experiences, it’s more convenient when you rely on time-management and provides more real-time analysis compared to ModuleScripts. I’m sorry for the messy explanation, but I hope this gives you a great idea.
Don’t want to say this, but likely an alternative.