Skip to content

Commit

Permalink
Merge pull request #4 from 1fabiopereira/develop
Browse files Browse the repository at this point in the history
refactor: refactor PitchDetectorModule.swift
  • Loading branch information
1fabiopereira authored Apr 7, 2023
2 parents be89c3d + 5250df3 commit 3c880b2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 32 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
name: Check Code Quality

on:
push:
branches: [main, master, develop]
pull_request:
branches: [main, master, develop]
branches: [main, develop]

jobs:
lint-and-tests:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Generate Documentation

on:
pull_request:
branches: [main]
push:
branches: [main]

Expand Down
2 changes: 1 addition & 1 deletion example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ SPEC CHECKSUMS:
React-jsiexecutor: 1579bf3207afadc72ac3638a66a102d1bf5263e3
React-jsinspector: 14a342151ab810862998dfc99e2720746734e9b3
React-logger: 94ec392ae471683635e4bf874d4e82f675399d2d
react-native-pitch-detector: 89ba140b11ebe97eb30d2e0f1f5be4fb06b8e64e
react-native-pitch-detector: 1208843b2b47df38210a8ed5cf4905e35457b858
React-perflogger: 883a55a9a899535eaf06d0029108ef9ef22cce92
React-RCTActionSheet: 1a3b8416688a3d291367be645022886f71d6842a
React-RCTAnimation: e5560cb72d91ba35151d51e2eb0d467b42763f43
Expand Down
38 changes: 12 additions & 26 deletions ios/PitchDetector/PitchDetectorModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,46 +34,32 @@ open class PitchDetectorModule: RCTEventEmitter {
}

@objc(start:resolve:reject:)
func start(
_ config: Dictionary<String, Any>,
resolve:@escaping RCTPromiseResolveBlock,
reject:@escaping RCTPromiseRejectBlock
) -> Void {
func start(_ config: Dictionary<String, Any>, resolve:@escaping RCTPromiseResolveBlock, reject:@escaping RCTPromiseRejectBlock) -> Void {
if (!self.recording) {
let promise = PromiseUtils(resolve, reject)
do {
processor.start(config)
self.recording = true
promise.resolve(nil)
} catch {
self.recording = false
promise.reject(error as NSError)
}

processor.start(config)
self.recording = true

return promise.resolve(nil)
}
}

@objc(stop:reject:)
func stop(resolve:@escaping RCTPromiseResolveBlock,reject:@escaping RCTPromiseRejectBlock) -> Void {
if (self.recording) {
let promise = PromiseUtils(resolve, reject)
do {
processor.stop()
self.recording = false
promise.resolve(nil)
} catch {
self.recording = false
promise.reject(error as NSError)
}

processor.stop()
self.recording = false

return promise.resolve(nil)
}
}

@objc(isRecording:reject:)
func isRecording(resolve:@escaping RCTPromiseResolveBlock,reject:@escaping RCTPromiseRejectBlock) -> Void {
let promise = PromiseUtils(resolve, reject)
do {
promise.resolve(self.recording)
} catch {
promise.reject(error as NSError)
}
return promise.resolve(self.recording)
}
}

0 comments on commit 3c880b2

Please sign in to comment.