1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-28 11:35:35 +03:00

Use weak instead of unowned

This commit is contained in:
Tae Won Ha 2019-03-23 10:42:49 +01:00
parent 40e72cd729
commit 867c066179
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44

View File

@ -93,8 +93,7 @@ class PreviewTool: NSView, UiComponent, WKNavigationDelegate {
if state.preview.status == .markdown
&& state.previewTool.isForwardSearchAutomatically
&& state.preview.editorPosition.hasDifferentMark(as: self.editorPosition)
{
&& state.preview.editorPosition.hasDifferentMark(as: self.editorPosition) {
self.forwardSearch(position: state.preview.editorPosition.payload)
}
@ -120,10 +119,13 @@ class PreviewTool: NSView, UiComponent, WKNavigationDelegate {
self.webviewMessageHandler.source
.throttle(0.75, latest: true, scheduler: self.scheduler)
.subscribe(onNext: { [unowned self] (position, scrollTop) in
self.previewPosition = position
self.scrollTop = scrollTop
self.emit(UuidAction(uuid: self.uuid, action: .scroll(to: self.previewPosition)))
.subscribe(onNext: { [weak self] position, scrollTop in
guard let uuid = self?.uuid,
let previewPosition = self?.previewPosition else { return }
self?.previewPosition = position
self?.scrollTop = scrollTop
self?.emit(UuidAction(uuid: uuid, action: .scroll(to: previewPosition)))
})
.disposed(by: self.disposeBag)
}
@ -163,11 +165,11 @@ class PreviewTool: NSView, UiComponent, WKNavigationDelegate {
private let webviewMessageHandler = WebviewMessageHandler()
private let automaticForwardMenuItem = NSMenuItem(title: "Automatic Forward Search",
action: nil,
keyEquivalent: "")
action: nil,
keyEquivalent: "")
private let automaticReverseMenuItem = NSMenuItem(title: "Automatic Reverse Search",
action: nil,
keyEquivalent: "")
action: nil,
keyEquivalent: "")
private let refreshOnWriteMenuItem = NSMenuItem(title: "Refresh on Write", action: nil, keyEquivalent: "")
private let log = OSLog(subsystem: Defs.loggerSubsystem,