georgymishin / react-native-silent-listener Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Hi there, I would like to contribute to the project, I've already made the changes in local and if you want I can push the patch for PR review. Basically I've just added a check for an initialValue reported and paused/resumed Mute on the startObserving/stopObserving methods. This allows to have a more trusted detection for startup.
Here below is the diff:
var previousValue: Bool = false
var hasListeners: Bool = false
-
+ var initialValueReported: Bool = false
+
override init() {
super.init()
-
+
Mute.shared.checkInterval = 2.0
Mute.shared.alwaysNotify = true
-
+ Mute.shared.isPaused = true
Mute.shared.notify = onNotify
}
-
+
@objc func setInterval(_ newInterval: NSNumber) {
Mute.shared.checkInterval = Double(newInterval);
}
-
+
func onNotify(_ newVal: Bool) {
- if previousValue == newVal {
- return
- }
-
- previousValue = newVal
if hasListeners {
+
+ if previousValue == newVal && self.initialValueReported {
+ return
+ }
+
+ self.initialValueReported = true
+ previousValue = newVal
+
sendEvent(withName: "onSilentChange", body: newVal)
+
}
}
-
+
override func startObserving() {
self.hasListeners = true
+ Mute.shared.isPaused = false
}
-
+
override func stopObserving() {
self.hasListeners = false;
+ Mute.shared.isPaused = true
}
}
Hi!
I have an issue, when run pod install
react-native-silent-listener
does not specify a Swift version and none of the targets (XXX
) integrating it have the SWIFT_VERSION
attribute set. Please contact the author or set the SWIFT_VERSION
attribute in at least one of the targets that integrate this pod.A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.