Skip to content
This repository has been archived by the owner on May 12, 2022. It is now read-only.

Commit

Permalink
Enhancement Init
Browse files Browse the repository at this point in the history
  • Loading branch information
muukii committed Apr 3, 2017
1 parent 0cb2e77 commit 00cb9b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 4 additions & 0 deletions OneStore/NonOptionalOneStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ open class NonOptionalOneStore<T: OneStoreValueProtocol>: OneStoreType {
}
}

public convenience init<R: RawRepresentable>(stack: Stack, key: R, initializedValue: T) where R.RawValue == String {
self.init(stack: stack, key: key.rawValue, initializedValue: initializedValue)
}

open var value: T {
get {
guard let value = source.value else {
Expand Down
8 changes: 2 additions & 6 deletions OneStore/OneStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,8 @@ open class OneStore<T: OneStoreValueProtocol>: OneStoreType {
}
}

public init<T: RawRepresentable>(stack: Stack, key: T, initializedValue: T? = nil) where T.RawValue == String {

precondition(key.rawValue.isEmpty == false, "key must be not empty")

self.storeKey = key.rawValue
self.stack = stack
public convenience init<R: RawRepresentable>(stack: Stack, key: R, initializedValue: T? = nil) where R.RawValue == String {
self.init(stack: stack, key: key.rawValue, initializedValue: initializedValue)
}

open var value: T? {
Expand Down

0 comments on commit 00cb9b6

Please sign in to comment.