Skip to content

Commit

Permalink
remove Ghost concept
Browse files Browse the repository at this point in the history
  • Loading branch information
omochi committed Apr 24, 2024
1 parent 8f52f9c commit 34496e1
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 66 deletions.
32 changes: 0 additions & 32 deletions Sources/React/Element/Component.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,12 @@ public protocol Component: Element {
var deps: Deps? { get }

func render() -> Node

static func _extractGhost(_ input: GhostInput<Self>) -> Ghost
}

extension Component {
public var key: AnyHashable? { nil }

public var deps: Deps? { nil }

static func extractGhostDefault(_ input: GhostInput<Self>) -> Ghost {
let hooks = extractHooks(input.component)

return Ghost(
component: input.component,
hooks: hooks
)
}

static func extractHooks(_ value: Any) -> [any _AnyHookWrapper] {
var hooks: [any _AnyHookWrapper] = []

let mirror = Mirror(reflecting: value)
for mc in mirror.children {
switch mc.value {
case let hook as any _AnyHookWrapper:
hooks.append(hook)
case let hook as any Hook:
hooks += extractHooks(hook)
default: break
}
}

return hooks
}

public static func _extractGhost(_ input: GhostInput<Self>) -> Ghost {
extractGhostDefault(input)
}
}

enum Components {
Expand Down
28 changes: 0 additions & 28 deletions Sources/React/Element/Ghost.swift

This file was deleted.

6 changes: 0 additions & 6 deletions Sources/React/Hooks/Context/ContextValueProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ public struct ContextValueProvider<Value: ContextValue>: Component & _AnyContext

var _contextValueType: any ContextValue.Type { Value.self }
var _contextValue: any ContextValue { value }

public static func _extractGhost(_ input: GhostInput<Self>) -> Ghost {
var ghost = extractGhostDefault(input)
ghost.contextValue = (type: Value.self, value: input.component.value)
return ghost
}
}

internal protocol _AnyContextValueProvider {
Expand Down

0 comments on commit 34496e1

Please sign in to comment.