Sleitnick / AeroGameFramework

AeroGameFramework is a Roblox game framework that makes development easy and fun. The framework is designed to simplify the communication between modules and seamlessly bridge the gap between the server and client.
https://sleitnick.github.io/AeroGameFramework/
MIT License
216 stars 57 forks source link

Aero functionality extensions. #166

Closed MaximumADHD closed 4 years ago

MaximumADHD commented 4 years ago

This commit introduces some features that I added to my internal fork of Aero in Crown Academy. I also made some minor style tweaks to the code for broader readability.

I expect this to have a few rounds of feedback before it gets merged, so let me know what you think :)

autonordev commented 4 years ago

Your branch seems to have an error in AeroClient on line 187.

            service[methodName] = function (self, ...)
                local now = tick()

                if (fetchingPromise) then
                    local _,c = fetchingPromise:Await()
                    return table.unpack(c)
                elseif (cache == NO_CACHE or (cacheTTL > 0 and (now - lastCacheTime) > cacheTTL)) then
                    lastCacheTime = now
                    local args = table.pack(...)

                    fetchingPromise = Promise.Async(function (resolve, reject)
                        resolve(table.pack(v:InvokeServer(table.unpack(args))))
                    end)

                    local success, _cache = fetchingPromise:Await()

                    if (success) then
                        cache = _cache
                    end

                    fetchingPromise = nil
                    return table.unpack(_cache)
                end

                return table.unpack(cache)
            else
                service[v.Name] = function (self, ...)
                    return v:InvokeServer(...)
                end
            end

It seems like you may have intended to do this:

            service[methodName] = function (self, ...)
                local now = tick()

                if (fetchingPromise) then
                    local _,c = fetchingPromise:Await()
                    return table.unpack(c)
                elseif (cache == NO_CACHE or (cacheTTL > 0 and (now - lastCacheTime) > cacheTTL)) then
                    lastCacheTime = now
                    local args = table.pack(...)

                    fetchingPromise = Promise.Async(function (resolve, reject)
                        resolve(table.pack(v:InvokeServer(table.unpack(args))))
                    end)

                    local success, _cache = fetchingPromise:Await()

                    if (success) then
                        cache = _cache
                    end

                    fetchingPromise = nil
                    return table.unpack(_cache)
                else
                    service[v.Name] = function (self, ...)
                        return v:InvokeServer(...)
                    end
                end
            end
Sleitnick commented 4 years ago

I'm gonna close this for now since v1.7.0 is going to cause a lot of conflicts with this. We can revisit these features a bit later though.