Skip to content

Latest commit

 

History

History
223 lines (155 loc) · 5.71 KB

README.MD

File metadata and controls

223 lines (155 loc) · 5.71 KB

Wand 🪄 API for Any (thing) |

📦 An ideal API acts as the black box
⚡️ It’s possible to incapsulate whole data receiving and memory managment duty to one symbol
?

Medium.com Habr.com

In Unix-like computer operating systems, a pipeline is a mechanism for inter-process communication using message passing. A pipeline is a set of processes chained together by their standard streams, so that the output text of each process (stdout) is passed directly as input (stdin) to the next one. The second process is started as the first process is still executing, and they are executed concurrently.

💬 bash

command1 | command2 | command3

ls -l | grep key | less

🕊️ swift

#Create handler  
{ (bar: Bar) in

}
#Black box
prefix func | (handler: @escaping (Bar)->() )

#Call API
| { (bar: Bar) in

}
#Retreive data (profit)
handler(bar)

⚙️ usage

#Request current Location
|{ (location: CLLocation) in 

}

#Request .authorizedAlways permissions once
CLAuthorizationStatus.authorizedAlways | .one { status in
            
}

#Update Pedometer Data
|{ (data: CMPedometerData) in 

}

#Scan for Bluetooth Peripheral
|{ (peripheral: CBPeripheral) in 

}

#Wait for a Notification
UIWindow.keyboardWillShowNotification | { (n: Notification) in
            
}

#Enumerate Contacts
CNContact.predicateForContacts(matchingName: "John") | .every { (contact: CNContact) in
                        
}

#Scan a tag
|.every { (tag: NFCNDEFTag) in

}

#Perform Face Observation
URL(string: "http://example.com/image.jpg") | { (faces: [VNFaceObservation]) in

}

#Perform Pose Observation
data | .while { (bodies: [VNHumanBodyPoseObservation]) in
    bodies < 2
}

#Detect shake
|{ (motion: UIEvent.EventSubtype) in
    if motion == .motionShake {
                
    }
}
#Customization
let wand = |{ (hands: [VNHumanHandPoseObservation]) in

}

let request: VNDetectHumanHandPoseRequest = wand.obtain()
request.maximumHandCount = 4

let preview: AVCaptureVideoPreviewLayer = wand.obtain()
view.layer.addSublayer(preview!)

💡 Idea

Imagine that you have the black box that can give you an Any object.
You don't know what's already in the box or what will happen inside

Ask for object that you need |

🪄 Сoncept

Wand started from the idea about receiving anything in most efficient way.

Add one sign to completion handler and retreive the result 📦
ex Pipe
ex API

Feel free to contribute. You are welcome 🔬

📚 Books

  • 🖼️ Design Patterns: Elements of Reusable Object-Oriented Software (1994)
    GOF: Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides

  • 🧼 Clean Code: A Handbook of Agile Software Craftsmanship (2008)
    Robert C. Martin

  • 🎼 Introduction to TRIZ. Basic Concepts and Approaches (2015)
    G.S. Altshuller

  • 🏛️ Clean Architecture: A Craftsman's Guide to Software Structure and Design (2017)
    Robert C. Martin

  • 😜 The Inmates Are Running the Asylum:
    Why High Tech Products Drive Us Crazy and How to Restore the Sanity (2019)
    Alan Cooper (Author)

  • ⊶ Origin (2017)
    Dan Brown

Tasks

  • Contacts
  • CoreLocation
  • CoreMotion
  • NSNotification
  • CoreNFC
  • Vision
  • Rest
  • MultipeerConnectivity

Alex Kozin
El Machine 🤖
since 2008