Giter Club home page Giter Club logo

angular-bacon's People

Contributors

aleksir avatar djebbz avatar kristw avatar lauripiispanen avatar pkjedi avatar theefer 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

angular-bacon's Issues

Add license

It would be helpful to us if there were an explicit license for angular-bacon. Here's what the MIT license would look like:

The MIT License (MIT)

Copyright (c) 2013 Lauri Piispanen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Here are some other licenses you may want to use: http://opensource.org/licenses/
Thanks!

`$watchAsProperty` may emit duplicate value changes upon start

Consider the following lines of code:

$scope.test = 'initial';

var property = $scope.$watchAsProperty('test');

// Property will emit the scope variable's initial value
property.onValue(function (value) {
    console.log("I will be invoked twice with the same value:", value);
});

// Running the digest loop will run the Angular watch that feeds `property` and the same value will be emitted once more.
$scope.$digest();

It will log twice with value 'initial'. I understand why that technically happens, but I consider it very much counter-intuitive.

In my opinion, how one expects $watchAsProperty to behave is very obvious and intuitive: it should represent an Angular scope variable as Bacon property. In the context of this issue that means that it should only emit a value change once for the scope variable that is assigned to 'initial' at the very beginning and is left untouched from that point on.

I suggest changing the implementation of $watchAsProperty to check for equality in its Angular watch function, as also referred to in the Angular documentation (see last paragraph of $watch section and second example).

More specifically I suggest replacing the current watch function with:

scope[watchMethod](watchExp, function(newValue, oldValue) {
    if (newValue !== oldValue) {
        return bus.push(newValue);
    }
}, objectEquality);

This would prevent the confusingly duplicate value change events.

Props to you, man.

I'm learning AngularJS (I really like it), and I just discovered Bacon.js and FRP. Really great. So when stumbled upon your project, I had to tweet about it !

Project seems on standby though. Is it because you lost interest in it, or because you think it's enough for your needs ? Before asking I checked the tests and they seem to cover the tool, so I would favor the latter but I prefer I asking.

Again : props to you ! It's a crazy combo here !

`$watchAsProperty` may skip values

Because $scope.$watchAsProperty() returns a property that is constructed from a Bacon.Bus, it suffers from this issue.

Compare:

// Note that `$scope.test` does not exist.

var property = $scope.$watchAsProperty('test');

property.onValue(function (value) {
    console.log("I will be invoked once with value `undefined`:", value);
});

// Digest loop results in Angular running the watch function on `test`.
$scope.$digest();

to:

// Note that `$scope.test` does not exist.

var property = $scope.$watchAsProperty('test');

// The digest loop is run for whatever reason before the property is subscribed to.
$scope.$digest();

property.onValue(function (value) {
    // Even though Angular has executed the watch on `test` (like in the preceding example),
    // the new value has been lost because `property` had not been subscribed to yet at that
    // point in time.
    console.log("I will never be invoked");
});

// No matter how many times the digest loop runs in the future, that initial value for `test` has
// been lost forever.
$scope.$digest();

It may be intended Bacon behavior, but that doesn't mean it should be intended $watchAsProperty behavior.

In my opinion, how one expects $watchAsProperty to behave is very obvious and intuitive: it should represent an Angular scope variable as a Bacon property.

Where $scope.$watch assigns a listener that runs exactly once for every new value of a scope variable, $scope.$watchAsProperty should construct a property that emits a change event exactly once for every new value of a scope variable. Since the idea behind properties is that they hold on to their latest ("current") value, missing or skipping just a single value change causes unexpected behavior even if the property has not been subscribed to yet.

P.S. This issue is related to the similarly motivated #19.

Add support for `$watchCollection`

angular-bacon currently always uses $watch, which does not work for Arrays of Objects. Should we add a $watchCollectionAsProperty method that would use $watchCollection under the hood?

I'm happy to give this a go in a PR if it sounds sane.

Note that the Array or Object would still be treated as a single atomic value for the Property.

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.