Giter Site home page Giter Site logo

reactivekit's People

Contributors

aethe avatar anthonymillersf avatar cyexy avatar dcacenabes avatar eduardbosch avatar fishcharlie avatar iandundas avatar ibrahimkteish avatar jechol avatar jettf avatar leontedev avatar mattsson avatar maxcilauro avatar maxkramer avatar minsone avatar nayzak avatar npvisual avatar patrick-lind avatar srdanrasic avatar svachmic avatar tonyarnold avatar trupin avatar vrutberg avatar w4-hojin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

reactivekit's Issues

Unit Testing

In order for v2 to come out of beta, it must be unit tested. Hopefully I'll be able to do that within next week or two.

Animations on bounded TableView

Hi,

I'm working with a tableView bound to an observable collection. The animation parameter is set to true and I'm doing myObsCol.moveItemAtIndex(idx1 , toIndex: idx2 ). The animation I'D expect is both getting visually swapped, but they just disappear and reappear in their new locations. Any ideas on how to solve this problem?

Thx!

LEo

carthage update/build fails with Xcode7.2

Hi, carthage fails with error.

error: module file's minimum deployment target is tvos9.1

To debug this issue, I cloned ReactiveFoundation, have set up submodules, and carthage build --no-skip-current --platform tvos gave me this error.
Does anyone know what's going on here ?

 $ carthage build --no-skip-current --platform tvos 
*** xcodebuild output can be found in /var/folders/tr/3lftss053tqdh731cgt0w1p00000gn/T/carthage-xcodebuild.sHl5tG.log
*** Building scheme "ReactiveFoundation-tvOS" in ReactiveFoundation.xcworkspace
2015-12-11 18:53:40.230 xcodebuild[28972:1204056] ### Failed to load Addressbook class CNContactNameFormatter
2015-12-11 18:53:49.498 xcodebuild[29106:1204477] ### Failed to load Addressbook class CNContactNameFormatter
** BUILD FAILED **


The following build commands failed:
    CompileSwift normal x86_64 /Users/toshi0383/github/ReactiveFoundation/ReactiveFoundation/ReactiveNSObject.swift
    CompileSwift normal x86_64 /Users/toshi0383/github/ReactiveFoundation/ReactiveFoundation/RKKeyValueObservable.swift
    CompileSwift normal x86_64 /Users/toshi0383/github/ReactiveFoundation/ReactiveFoundation/ReactiveNSNotificationCenter.swift
    CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
(4 failures)
/Users/toshi0383/github/ReactiveFoundation/ReactiveFoundation/ReactiveNSObject.swift:25:8: error: module file's minimum deployment target is tvos9.1 v9.1: /Users/toshi0383/Library/Developer/Xcode/DerivedData/ReactiveFoundation-auqflbevjklmgsajwqibfmjzpgwu/Build/Products/Release-appletvsimulator/ReactiveKit.framework/Modules/ReactiveKit.swiftmodule/x86_64.swiftmodule
/Users/toshi0383/github/ReactiveFoundation/ReactiveFoundation/ReactiveNSObject.swift:25:8: error: module file's minimum deployment target is tvos9.1 v9.1: /Users/toshi0383/Library/Developer/Xcode/DerivedData/ReactiveFoundation-auqflbevjklmgsajwqibfmjzpgwu/Build/Products/Release-appletvsimulator/ReactiveKit.framework/Modules/ReactiveKit.swiftmodule/x86_64.swiftmodule
/Users/toshi0383/github/ReactiveFoundation/ReactiveFoundation/ReactiveNSObject.swift:25:8: error: module file's minimum deployment target is tvos9.1 v9.1: /Users/toshi0383/Library/Developer/Xcode/DerivedData/ReactiveFoundation-auqflbevjklmgsajwqibfmjzpgwu/Build/Products/Release-appletvsimulator/ReactiveKit.framework/Modules/ReactiveKit.swiftmodule/x86_64.swiftmodule
A shell task failed with exit code 65:
2015-12-11 18:53:49.498 xcodebuild[29106:1204477] ### Failed to load Addressbook class CNContactNameFormatter
** BUILD FAILED **


The following build commands failed:
    CompileSwift normal x86_64 /Users/toshi0383/github/ReactiveFoundation/ReactiveFoundation/ReactiveNSObject.swift
    CompileSwift normal x86_64 /Users/toshi0383/github/ReactiveFoundation/ReactiveFoundation/RKKeyValueObservable.swift
    CompileSwift normal x86_64 /Users/toshi0383/github/ReactiveFoundation/ReactiveFoundation/ReactiveNSNotificationCenter.swift
    CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
(4 failures)
$ carthage version 
0.11.0
$ xcodebuild -version
Xcode 7.2
Build version 7C68

Feature Request - Silent Update

As per the discussion in ReactiveKit/ReactiveUIKit#5, a feature for silently updating the value of an Observable should be added.

This is useful in many scenarios, including bi-directional binding of multiple dependent values and updating the datasource for a UICollectionView when an item has been moved.

Request: Timer

ReactiveCocoa has it's interval() method, and RxSwift has Observable.timer() — it would be great to have an equivalent in ReactiveKit.

Recursive subscript bug

I discovered a strange bug when I was using ObservableCollection. I'm modeling data for a collection view which is typically a 2D array.

My collection declaration:

var elements: ObservableCollection<[ObserverableCollection<[Element]>]> = ObservableCollection([])

When I would go and try to remove an element like so:

self.elements[indexPath.section].removeAtIndex(indexPath.item)

subscript in ObservableCollection+Array.swift (line 64) gets called recursively until the stack blows.

However, if I do this:

var observable = self.elements[indexPath.section]
observable.removeAtIndex(indexPath.item)

Everything works just fine.

This may all be happening because I'm modeling a 2D array Elements incorrectly. Ideally I'd like all the changes that happen in the inner arrays to be propagated up to the outside collection.

Binding an ObservableCollection to a Collection View

Hi,

is there any more extensive example of binding an observableCollection of a collectionView? I'm porting an app I had in SwiftBond to ReactiveKit. I'm trying using the way explained here in the documentation and also using some inspiration from the SwiftBond demo app but I can't seem to be able to figure it out. I either get:

malloc: *** error for object 0x7fa13512a718: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug

from the ReactiveUIKit extension, or

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of items in section 0. The number of items contained in an existing section after the update (29) must be equal to the number of items contained in that section before the update (29), plus or minus the number of items inserted or deleted from that section (29 inserted, 0 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out).'

on the same code. Any ideas or hints?

Thx!

LEo

Rationale of the new names in 2.0 beta?

Hi Srdan,

I was going over the migration guide for 2.0 and wondered about the new names for the common entities in ReactiveKit. It seems that for some of the new naming, you moved away from the naming used in other reactive frameworks. Would you care to give us some hints about the rationale you used for the new names?

Thanks!

LEo

How to merge a bunch of Streams into a single Stream of the last changed value from any?

Hi - I can't seem to find a merge function (as in here) for Streams, but maybe I'm thinking about it wrong:

Say I have a bunch of streams which send UIColor events. I'm interested in the latest value coming from any of them, I don't care which Stream it is, only the value sent most recently.

        let streamA: Stream<UIColor> ...
        let streamB: Stream<UIColor> ...
        let streamC: Stream<UIColor> ...
        let streamC: Stream<UIColor> ...
        let streamE: Stream<UIColor> ...

How would can I combine these streams together in a way that would achieve that? I have an inkling that it would involve a flatMap of type StreamFlatMapStrategy.Merge, but the transform block for that is of type: <(UIColor, UIColor, UIColor, UIColor, UIColor) -> StreamType, i.e. all the UIColor values together, where it's unclear which one changed.

Thanks in advance,

Plans to implement a collect() like function from RAC?

From the RAC documentation:

The collect operator is used to aggregate a event stream’s values into a single array value. Note that the final value is only sent after the input stream completes.

Any ideas on how one would accomplish that right now?

Basically, say there's a situation where you need to make many network calls, which if I'm correct would each be wrapped in an Operation. Say you would like to gather all of the "nexts" from each respective operation and proceed only when all of the operations have ended. How would one do that right now?

Turning observers on and off

Hi,

I'm observing a Stream and I would like to ignore the events while I change some other stuff in my model, and than start reacting again. Is it possible to pause or ignore the events of an observer for a while and then turn it on again, without having to dispose and recreate the observer?

Thx!

LEo

Keeping a reference to a dictionaryIndex leaks objects

Storing the indexForKey in the deletes-array of the ObservableCollectionEvent causes the related value in the dictionary to not be released.
This seems to be a bug in Swift, i filed a bugreport for it: 23952263

  public mutating func removeValueForKey(key: Index.Key) -> Index.Value? {
    if let index = collection.indexForKey(key) {
      var new = collection
      let oldValue = new.removeValueForKey(key)
      next(ObservableCollectionEvent(collection: new, inserts: [], deletes: [index], updates: []))
      return oldValue
    } else {
      return nil
    }
  }

Test-code:

class MyObject {
    var number : Int

    init(nr: Int){
        self.number = nr
    }

    deinit{
        print("deinit MyObject \(number)")
    }
}

class Model {
    static let instance = Model()

    var dict = ObservableCollection([1: MyObject(nr:1)])


    init(){
        Queue.main.after(5.0){
            self.dict[1] = nil
            print("MyObject-1 is not yet released")
            Queue.main.after(5.0){
                print("When adding another object (creating a new CollectionEvent), releases MyObject-1")
                self.dict[2] = MyObject(nr:2)
                Queue.main.after(5.0){
                }
            }
        }
    }
}

Operation .Success never called when using `flatMap`: what am I doing wrong here?

Hi! Would be very grateful if anyone could let me know what I'm doing wrong here:

github demo project

The below code is a simple Operation, which is called via a flatMap. The Operation simply calls observer.success(). I'd expect it to call print("success") - but this is never reached. If, however, I swap the line of code within the Operation to call .next(".."), this does reach the observe block.

Could anyone tell me why case .success doesn't get called in theobserve block?

import ReactiveKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    var disposable: DisposableType! // just in case

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

        func successOperation() -> Operation<String, NSError>{
            return Operation{observer in

                // observer.next("this *does* reach the observe block")

                observer.success() // this never reaches the observe block

                return SimpleDisposable()
            }
        }

        let a = ActiveStream<String>()
        let b = a.flatMap(OperationFlatMapStrategy.Latest) { whatever -> Operation<String, NSError> in
            return successOperation()
        }

        disposable = b.observe { event in
            switch event{
            case .Success:
                print("success") // never called

            default:
                print("anything else")
            }
        }

        a.next("sending something")

        return true
    }
}

Note, if I just observe the Operation directly, it does work:

disposable = successOperation().observe { event in
    switch event{
    case .Success:
        print("success") // this IS called now.

    default:
        print("anything else")
    }
}

Use of IndexOf in an observable collection

Hi,
I have an observable array and I want to use indexOf, but I'm not sure what to provide as the expected (predicate: (Element) throws -> Bool). Any hints?

Thx!

LEo

PS: Happy new year! :-)

How to combine a list of operations ?

Hi, I'm new to Reactive Programming.
Is it possible to do something like this ?

combineLatest(numbers.flatMap(createOperationsFromNumbers))
    .observe(on: ImmediateExecutionContext) { e in}

carthage update fails

 $ carthage update  
*** Fetching ReactiveFoundation
*** Fetching ReactiveUIKit
*** Fetching ReactiveKit
*** Checking out ReactiveKit at "v1.0.8"
*** Checking out ReactiveFoundation at "v1.0.4"
*** Checking out ReactiveUIKit at "v1.0.6"
*** xcodebuild output can be found in /var/folders/tr/3lftss053tqdh731cgt0w1p00000gn/T/carthage-xcodebuild.6LzfqB.log
Failed to discover shared schemes in project Quick.xcodeproj—either the project does not have any shared schemes, or xcodebuild never returned

The log file is empty.

$ xcodebuild -version
Xcode 7.1
Build version 7B91b

After removing Carthage/ dir, got same error.

'NOT','OR' operation support?

I love this kit so much, Thank you for your effort。
we often meet such requirements, two buttons A and B,the state of them is:if A selected B must Normal,if B selected A must be Normal.
In ReactiveCocoa i can achieve easily, but i can't find similar operation In ReactiveKit .

performDiff for replace in obsrvable collections

Hi,

I'm trying to use
myArray.replace(myNewArray, performDiff: true)

but the results doesn't seem to be right. I get in the inserts and deletes array what seems to be the indexes of the replaced elements:

Collection before:: [36, 37]
Collection after:: [43, 44]
ObservableCollectionEvent<Array<Int>>(collection: [43, 44], inserts: [0, 1], deletes: [0, 1], updates: [])

Am I doing something wrong?

Thx!

LEo

Handling error in composition

Hi,

I was checking the example in the documentation about composing operations. What I can't figure out is how to handle errors. Is it possible to have one common error handler for the whole chain of composed operations? Ideally, this handler should be called if any of the operations in the chain fails.

Thx,

LR

Exponential and Fixed Backoff For the Operation Retry method

Having exponential and fixed backoff for the operation and retry method on Operation would be very useful. One way of doing it would be the following:

enum Backoff { case Exponential(Double) case Fixed(Double) case None }

public func retry(var count: Int) -> Operation<Value, Error>
would become
public func retry(var count: Int, backoff : Backoff = .None) -> Operation<Value, Error>

I can implement this if need be.

Removing from an observable collection results in a crash

The error occurs when the ObservableCollection is sorted

The bug can be reproduced with the following code:

var collection = ObservableCollection([1, 3, 2, 5])
var sorted = collection.sort { $0 < $1 }
while(collection.count > 1) {
  collection.removeLast()
}

The error happens in ObservableCollectionEvent.swift at line 106: let newDeletes = deletes.map { sortMap[$0]! }
fatal error: unexpectedly found nil while unwrapping an Optional value

Values of the variables when the error occurs:
sortMap: [0: 0, 2: 1, 1: 2]
inserts: []
deletes: [3]
updates: []

The error seems to be that the value to be removed is already removed from the sortMap and is still tried to find from there. Therefore, this issue occurs always when removing the last element of the ObservableCollection when there's a collection derived from it.

observeNew

There was an observeNew function in Bond that seems not to be here in ReactiveKit. Is there another way of getting the same functionality as the observeNewfunction?

Thanks!

Advice on avoiding deadlocks?

I'm running into deadlocks at Queue.sync(), usually related to either trying to setup two-way bindings or when feeding a result back into a chain. For example, here I want to ensure that endDate is never earlier than startDate:

let startDate = ActiveStream<NSDate>()
endDate = ActiveStream<NSDate?>()

combineLatest(startDate, endDate).map { startDate, endDate -> NSDate? in
    guard let endDate = endDate else {return nil}

    if endDate.isEarlierThanDate(startDate) || endDate.isEqualToDateIgnoringTime(startDate){
        return startDate.dateByAddingDays(1)
    }
    return endDate
}.distinctOptional().bindTo(endDate)

It's not an infinite loop, because whenever I pause execution the debugger is just parked at Queue.sync() (and if I put a breakpoint log there, I can see it's not being called repeatedly).

If I try to be specific about the context that it should use, it still doesn't help:

startDate.combineLatestWith(endDate).switchTo(ImmediateExecutionContext).map { startDate, endDate -> NSDate? in
    guard let endDate = endDate else {return nil}

    if endDate.isEarlierThanDate(startDate) || endDate.isEqualToDateIgnoringTime(startDate){
        return startDate.dateByAddingDays(1)
    }
    return endDate
}.distinctOptional().bindTo(endDate, context: ImmediateOnMainExecutionContext)

I can get it to work in an observe, but only if I specifically call .next asynchronously, i.e.:

combineLatest(startDate, endDate).observe { [weak self] startDate, endDate in
    guard let strongSelf = self else {return}
    guard let endDate = endDate else {return}

    if endDate.isEarlierThanDate(startDate) || endDate.isEqualToDateIgnoringTime(startDate){
        Async.main{ // prevents deadlock
            strongSelf.endDate.next(startDate.dateByAddingDays(1))
        }
    }
}

I'd appreciate any pointers to either what am I doing wrong or another approach for tackling this,

Cheers

Trying to implement a take(x) operator

Hi - I'm trying to implement a take(x) operator, but I'm running into some problems creating my Stream.

extension StreamType{
    public func take(count:Int) -> Stream<Self.Event> {
        return Stream { observer in
            let simpleDisposable = SimpleDisposable()

            var remainder = count
            self.observe(on: nil, observer: { (event) -> () in
                if remainder > 0{
                    observer(event)
                    remainder--

                    if remainder == 0{
                        simpleDisposable.dispose()
                    }
                }
                else{
                    print("WAS NOT DISPOSED")
                }
            })
            return simpleDisposable
        }
    }
}

This was my attempt - however the WAS NOT DISPOSED is being logged, showing that I've not torn down the observe(). I'll keep looking into it (and will post followup), just wondering if anyone has any suggestions for what I missed.

Cheers - Ian

Enhancement: ObservableCollection propagate events up to super collection

It'd be great if I could have an ObservableCollection of type ObservableCollection<T> like this:

let observable: ObservableCollection<[ObservableCollection<[Model]>]>

such that any changes to the inner observable collection will propagate up to the outside observer. This relates to this issue in ReactiveUIKit, so that you can have a 2D array of observables which will allow the consumer to have multiple sections.

Possible retain cycle

Hi guys. What i was trying to do is to create a custom operator that could restart Operation after some delay. So i took 'retry' function and changed it a bit. But when i started testing, it looked like i had some memory leaks or retain cycles. I returned back to ‘retry’ but got same results.

Here is what i have.

A simple downloader class which always generates errors in order to test ‘retry’.

class Service {
   static func operationToTestRetainCycle(address address: String) -> Operation<Int, NSError> {
        return Operation { observer in

            print("[Service]: send request")

            let request = Alamofire
                .request(.GET, address)
                .responseString { response in
                    let error = NSError(domain: "TestDomain", code: 0, userInfo: nil)
                    observer.failure(error)
                }

            return BlockDisposable() {
                request.cancel()
            }
        }
    }
}

A worker class. An instance created after a tap on a button and destroyed after another tap.

private class Worker {
    var memTest = MemTest(name: "Worker")
    var operation: Operation<Int, NSError>?
    var disposable: DisposableType?

    deinit {
        disposable?.dispose()
    }

    func start() {
        operation = Service.operationToTestRetainCycle(address: "http://google.com").retry(3)
        disposable = operation!.observe { event in
            NSLog("[Worker] received event \(event)")
        }
    }
}

I wanted to check that all Operations are released after the Worker object is released, but i could not add deinit, because Operation is a structure. So i added a helper class MemTest:

public class MemTest {
    let name: String

    public init(name: String) {
        self.name = name
        NSLog("[\(name)]: init \(unsafeAddressOf(self))")
    }

    deinit {
        NSLog("[\(self.name)]: deinit \(unsafeAddressOf(self))")
    }
}

And added a variable to the Operation:

public struct Operation<Value, Error: ErrorType>: OperationType {
  private let memTest = MemTest(name: "Operation")

}

When Operation is released, MemTest is released and i can see logs.

Logs are:

<Tap>
[Worker]: init 0x00007fdab242bcd0
[Operation]: init 0x00007fdab270b960
[Operation]: init 0x00007fdab2714ab0
[Service]: send request
[Service]: send request
[Service]: send request
[Service]: send request
[Worker] received event Failure(Error Domain=TestDomain Code=0 "(null)")
<Tap>
[Worker]: deinit 0x00007fdab242bcd0
[Operation]: deinit 0x00007fdab2714ab0

As you can see MemTest with address 0x00007fdab270b960 is not released.

Trying to fix i transformed Operation into a class and added [weak self] in the ‘retry’:

    @warn_unused_result
  public func retry(var count: Int) -> Operation<Value, Error> {
    return create { observer in
      let serialDisposable = SerialDisposable(otherDisposable: nil)

      var attempt: (() -> Void)!

      attempt = {[weak self] in
        serialDisposable.otherDisposable?.dispose()
        serialDisposable.otherDisposable = self?.observe(on: nil) { event in
          switch event {
          case .Failure(let error):
            if count > 0 {
              count--
              attempt()
            } else {
              observer.failure(error)
            }
          default:
            observer.observer(event._unbox)
          }
        }
      }

      attempt()
      return serialDisposable
    }
  }

Logs after:

<Tap>
[Worker]: init 0x00007fdc2b526f30
[Operation]: init 0x00007fdc2b54da60
[Operation]: init 0x00007fdc2b540370
[Service]: send request
[Service]: send request
[Service]: send request
[Service]: send request
[Worker] received event Failure(Error Domain=TestDomain Code=0 "(null)")
<Tap>
[Worker]: deinit 0x00007fdc2b526f30
[Operation]: deinit 0x00007fdc2b540370
[Operation]: deinit 0x00007fdc2b54da60

Weird behaviour of bound UITableView

Hi,

I'm using a table view bounded to an array and I implemented the methods for allowing deletion of a row using a swipe gesture. To react to the press of "delete" I implemented the corresponding method:
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath)

But for some reason once I tap the delete button, the binding is lost and my table loses all it's rows. If I rebind the table, the rows appear again. Any ideas why this might be happening?

Thanks!

LEo

Leaks

Hi,

I have been working on an application for a while using reactive kit and today I notice that my app has a lot of memory leaks. As it seems, probably coming from the use of observable vars and collection. They seem to creating a lot of retain cycles all the time. Can somebody give me some advice on how to avoid retain cycles while using ReactiveKit and how to break them once they appear? I am little out of clues here, as I tried several different things.

Thanks.

L.

PS: It seems like the development of ReactiveKit has slowed down or come to a stop. Is it still being developed?

Improve unit tests coverage

Tests are currently written using Quick. We use carthage (--no-build --use-submodules) as the dependency manager, but I'm not sure about that - it still has too many issues.

After you clone the repo do git submodule update --init. It should also be possible to do carthage bootstrap --no-build --use-submodules instead, but that usually fails for me.

Use Xcode workspace file.

Observable - declaration operators

So I kinda did not like the way properties are being set in class. Having to say it is Observable<String?>.

What about introduing simple operator:

class SomeObject {

    var val: Bool

    init(val: Bool) {
        self.val = val
    }

}

prefix operator § {}
prefix operator §! {}
prefix operator §? {}

prefix func § <T: Any> (type: T) -> Observable<T> {
    return Observable<T>()
}

prefix func §! <T: Any> (type: T!) -> Observable<T!> {
    return Observable<T!>()
}

prefix func §? <T: Any> (type: T?) -> Observable<T?> {
    return Observable<T?>()
}

let some = §34
let other = §?"Some string"
let yetAnother = §!SomeObject(val: false)

Do you thing it is overkill that would cause just confusing or it is actually something that makes sense?
I did not figure out how to do it in type definition of the property. Same could apply to setting of observable.

Reactive Kit : Sample Application

Hey guys ,
is there any sample application which use all of features of this kit ?
that would be nice if we can have this in this code base.

Thanks
Fazeel

collectionView bounded to observableArray not updating after

Hi,

I have a CollectionView bound to an observable array, and I'm removing one element from the observable array:

myObservableArray.removeAtIndex(index.item)

but after doing that, contrary to what I would expect, the number of elements in the observable array is different to the number of elements in the collection:

print("-->", myObservableArray.count, myCollectionView.numberOfItemsInSection(0))

-->  2  3

Shouldn't both values be the same?

Simple example on rValueForKeyPath?

From what I understand is that rValueForKeyPath is an NSObject extension to observe property changes? I have tried a few different ways to observe but so far I haven't been abel to get the observe events to fire properly

class SometViewModel{

var testObj= TestClass()
init(){
    testObj.test = "hello"

    delay(3){  //a delay timer
        self.testObj.test = "hello2"
    }

    testObj.rValueForKeyPath("test").observe{(value: String?) in
        print("Received: \(value)")
    }

}

class TestClass:NSObject{
    dynamic var test:String=""
}
}

How to use StreamType sample()?

I'm having a bit of trouble getting StreamType's sample() function to work — it fires once, then never again. What do I need to retain? The disposable or the operation? Thanks!

Ready for prod?

Can I use ReactiveKit on prod now?
I'm afraid of beta.

Or should I use ReactiveKit 1.1.3?
Or Bond?

Thanks for your hard working.

Would an Event class make sense?

I'm currently writing an iOS app using the view-model pattern realized with ReactiveKit (formerly Bond). For some scenarios I would like to have simple events I can observe and trigger—basically Observables without the value.

I'm currently using ActiveStreams for that and call next for triggering them. But that doesn't feel right. Would it be a good idea to introduce an Event class with a trigger method? It might simply be a subclass of ActiveStream and call self.next() on trigger, but the naming would be much more descriptive.

Now, does it even make sense to have such a "pure" event type? I'm kinda new to reactive programming and don't know if that fits the pattern.

Is is sensible to always deliver on main thread?

Wouldn't it be more suitable to use main thread in the UIKit-library rather than the abstract one? Bindings can in fact be used outside the main thread for various reasons.

For example, one can have several reusable and independent view models, which are composed to create a screen model. Those smaller models will likely use bindings for communication between each other, should they need it. Then, this communication can be performed off the main thread. But right now it will be scheduled on the main thread implicitly.

What I suggest is to force main thread scheduling in the UIKit extensions, where it seems quite sensible, and make immediate scheduling the implicit one for the ReactiveKit abstract library.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.