Skip to content

Commit

Permalink
fix: linter
Browse files Browse the repository at this point in the history
  • Loading branch information
michalsek committed Dec 4, 2024
1 parent cfa3e96 commit afe9818
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class AudioBus;
class AudioBuffer : public std::enable_shared_from_this<AudioBuffer> {
public:
explicit AudioBuffer(int numberOfChannels, int length, int sampleRate);
AudioBuffer(AudioBus *bus);
explicit AudioBuffer(AudioBus *bus);

[[nodiscard]] int getLength() const;
[[nodiscard]] int getSampleRate() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jsi::Value PromiseVendor::createPromise(std::function<void(std::shared_ptr<Promi
resolve->call(runtime, *valueShared);
});
};

auto rejectWrapper = [reject, &runtime, callInvoker](const std::string& errorMessage) -> void {
auto error = jsi::JSError(runtime, errorMessage);
auto errorShared = std::make_shared<jsi::JSError>(error);
Expand All @@ -55,4 +56,4 @@ jsi::Value PromiseVendor::createPromise(std::function<void(std::shared_ptr<Promi
return promiseCtor.callAsConstructor(runtime, runPromise);
}

}
} // namespace JsiPromise
17 changes: 10 additions & 7 deletions packages/react-native-audio-api/common/cpp/utils/JsiPromise.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

#include <ReactCommon/CallInvoker.h>
#include <jsi/jsi.h>
#include <utility>
#include <memory>
#include <string>

namespace JsiPromise {

using namespace facebook;

class Promise {
public:
public:
Promise(std::function<void(jsi::Value)> resolve, std::function<void(const std::string&)> reject): _resolve(std::move(resolve)), _reject(std::move(reject)) {}
public:

bool isResolved;
void resolve(jsi::Value&& value) {
_resolve(std::forward<jsi::Value>(value));
Expand All @@ -19,21 +22,21 @@ class Promise {
_reject(errorMessage);
}

private:
private:
std::function<void(jsi::Value)> _resolve;
std::function<void(const std::string&)> _reject;
};

class PromiseVendor {
public:
public:
PromiseVendor(jsi::Runtime* runtime, std::shared_ptr<react::CallInvoker> callInvoker): _runtime(runtime), _callInvoker(callInvoker) {}

public:
public:
jsi::Value createPromise(std::function<void(std::shared_ptr<Promise>)> func);

private:
private:
jsi::Runtime* _runtime;
std::shared_ptr<react::CallInvoker> _callInvoker;
};

}
} // namespace JsiPromise

0 comments on commit afe9818

Please sign in to comment.