lauripiispanen / angular-bacon Goto Github PK
View Code? Open in Web Editor NEWAngular-bacon.js bindings
License: MIT License
Angular-bacon.js bindings
License: MIT License
A release was never rolled with the newer bacon version. This should be done.
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!
warning "angular-bacon > [email protected]" has incorrect peer dependency "grunt@~0.4.0".
Why is this an actual dependency and not only a dev-dependency?
line 52 of form-validation.js in examples raises this error:
Error: not an EventStream : Bacon.Bus().toProperty().map(function)
this is the line:
.merge(usernameInput.map(false))
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.
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 !
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.
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.
Can you please use umd wrapper and publish the module to npm?
Use of $apply is discouraged, but this will cause stream digests to always be evaluated asynchronously. Test cases will be affected, but must also try to check if this has other implications to existing code.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.