Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(callback): allow type table for cb #668

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

loaf-scripts
Copy link

Makes it so you can pass callbacks from RegisterNUICallback etc

Makes it so you can pass callbacks from RegisterNUICallback etc
@jag3dagster
Copy link
Member

The use case that you described doesn't make a lot of sense. Could you give a more complete usage example for this functionality and how you imagine it working.

@loaf-scripts
Copy link
Author

An example would be to get a presigned URL to upload an image to Fivemanage.

Example client code:

RegisterNUICallback("getPresignedUrl", function(body, cb)
    lib.callback("getPresignedUrl", false, cb)
end)

With the latest version of ox_lib, this results in the following error:
error during NUI callback getPresignedUrl: @ox_lib/imports/callback/client.lua:77: expected argument 3 to have type 'function' (received table)

Another example would be an export that takes cb as an argument, e.g:

exports("GetData", function(cb)
    lib.callback("getData", false, cb)
end)

Currently, that would return the following error:
image

@jag3dagster
Copy link
Member

Hm based on this commit 2909cb5 it looks like @thelindat is against this sort of functionality. I'll leave it up to him to decide if he thinks this use case is an exception.

@jag3dagster jag3dagster requested a review from thelindat January 16, 2025 21:57
@thelindat
Copy link
Member

The explained issue doesn't really make sense since nui callbacks aren't tables; so this is really just a fix for function references (still kind of weird/unnecessary usage tbh). What actually needs to be checked here is if it's a function or a table with a __call method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants