Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 18:34
    greenkeeper[bot] labeled #5444
  • 18:34
    greenkeeper[bot] opened #5444
  • 18:34

    greenkeeper[bot] on can-observable-mixin-1.0.7

    fix(package): update can-observ… (compare)

  • 18:30

    cherifGsoul on update-infrastructure-page

    (compare)

  • 18:30

    cherifGsoul on master

    Update infrastructure page with… (compare)

  • 18:30
    cherifGsoul closed #5441
  • 18:30
    cherifGsoul closed #5417
  • Dec 10 17:40
    cherifGsoul review_requested #5443
  • Dec 10 16:47
    cherifGsoul review_requested #5441
  • Dec 10 16:35
    cherifGsoul synchronize #5441
  • Dec 10 16:35

    cherifGsoul on update-infrastructure-page

    Fix typos (compare)

  • Dec 10 10:01
    jkeruzec starred canjs/canjs
  • Dec 09 18:59
    cherifGsoul review_requested #5443
  • Dec 09 18:59
    cherifGsoul opened #5443
  • Dec 09 18:51

    cherifGsoul on document-inserted-removed-can6

    Add inserted/removed events to … (compare)

  • Dec 09 15:38
    greenkeeper[bot] labeled #5442
  • Dec 09 15:38
    greenkeeper[bot] opened #5442
  • Dec 09 15:38

    greenkeeper[bot] on can-view-live-5.0.1

    fix(package): update can-view-l… (compare)

  • Dec 08 21:21
    greenkeeper[bot] commented #5392
  • Dec 08 21:21

    greenkeeper[bot] on core-js-3.4.8

    chore(package): update core-js … (compare)

opolyo01
@opolyo01
3 components will call this model and I get 3 console.log printed
Justin Meyer
@justinbmeyer
@opolyo01 can you put that in a ```
@patrickclancy regarding model validation ... I would not use our validation plugin
it's probably more simple to use the define plugin
Patrick Clancy
@patrickclancy
@justinbmeyer how would you suggest using the define plugin?
Ilya Fadeev
@ilyavf
@justinbmeyer Like, have a compute property which iterates through my list of items and reads item's property I am interested to listen to?
Patrick Clancy
@patrickclancy
with getters and setters
Justin Meyer
@justinbmeyer
@patrickclancy something like:
define: {
  isNameValid: {
    get: function(){
      return !!this.attr("name")
    }
  }
}
and you could create "mixins" that help set this up
define: validators({}, validateExists("name"))
opolyo01
@opolyo01
@daffl So yeah, promiseStore[ key ].then will be rejected within my components scope, but no while I am in the model. So I wonder would could reject the promise? I know I don't do .reject anywhere
Justin Meyer
@justinbmeyer
@ilyavf yes
do this in the view model
Patrick Clancy
@patrickclancy
@justinbmeyer interesting… I like using the define plugin… everything else is there. I’d need to roll in the check all type functionality that model.errors() provides. But that wouldn’t be hard
Justin Meyer
@justinbmeyer
yeah, the check functionality
is the one thing that this is missing
but in my opinion, having observability
is more important
oh, you mean check all
nm, that can be observable too
I am talking about the "if I set this, will it create an error"
behavior of validations
so you don't actually have to commit a breaking set
to see if there's an error
Patrick Clancy
@patrickclancy
@justinbmeyer is this the direction you’re thinking validation will go? We’ve got models with 60+ fields and observable is important. Bummer I just spent all day doing it the old way
@justinbmeyer I haven’t used this workflow "if I set this, will it create an error”. becasue of can-value live binding. I’d like to integrate that but haven’t
Justin Meyer
@justinbmeyer
yes, validation will certainly be observable
and probably be a plugin into the define plugin itself
if validations are important I can help you create something that bridges the gap
are you using stealjs?
Patrick Clancy
@patrickclancy
yes with ES6 syntax
Justin Meyer
@justinbmeyer
If you are using StealJS, we could create a can-validate repo and add you as a contributor
Patrick Clancy
@patrickclancy
wow… sounds good
Justin Meyer
@justinbmeyer
either @daffl or I could put a day in or so to get the basics working
@patrickclancy added you to: https://github.com/canjs/can-validate
can you create an issue with what you'd like?
perhaps something very close to the old validation but observable
oh, @patrickclancy using npm to install deps hopefully?
@daffl anyway you can setup a "shell" project sometime tomorrow? It can look like can-connect
btw, @patrickclancy not sure if you've seen can-connect
but I am aiming to have the docs done this week
Patrick Clancy
@patrickclancy
@justinbmeyer YES!! the only way to go. (can 2.3-pre as well)
@justinbmeyer I’ve seen can-connect and I’d like to use it but… docs would help
Justin Meyer
@justinbmeyer
ok, great, that will make working on can-validate stupidly easy
Patrick Clancy
@patrickclancy
@justinbmeyer Is place my order the best way to see can-connect in action?
Justin Meyer
@justinbmeyer
currently yes, but my docs will have demos
Patrick Clancy
@patrickclancy
@justinbmeyer sweet… thank you
Justin Meyer
@justinbmeyer
import connect from "can-connect";
import "can-connect/data/url/";
import "can-connect/constructor/";
import "can-connect/constructor/store/";
import fixture from "can/util/fixture/";

// A connection that gets todos data
var todosConnection = connect(["constructor-store","constructor","data-url"],{
  url: "/todos"
});

// Trap ajax requests to return and modify the following `todo` object.
var todo = { 
    id: 5, 
    name: "do the dishes"
};
fixture({
    "GET /todos/{id}": function(){
        todo.date = (+new Date());
        return todo;
    },
    "PUT /todos/{id}": function(request){
        todo.name = request.data.name;
        return {name: request.data.name, date: +new Date()};
    }
});

var makeTodoNamer = function(id){
    var element = document.createElement('div');
    var todo;

    var update = function(){
        element.firstChild.value = todo.name;
        element.childNodes[2].innerHTML = todo.date % 1000;
    };

    element.innerHTML = "<input/><button>X</button><span/>";

    todosConnection.get({id: id}).then(function(retrievedTodo){
        todo = retrievedTodo;
        Object.observe(todo,update, ["update"] );
        todosConnection.addInstanceReference(todo);
        update();
    });

    element.childNodes[1].onclick = function(){
        Object.unobserve(todo, update, ["update"] );
        todosConnection.deleteInstanceReference(todo);
        element.parentNode.removeChild(element);
    };
    element.firstChild.onchange = function(){
        todo.name = this.value;
    };

    element.firstChild.onkeypress = function(ev){
        if(ev.keyCode === 13) {
            todo.name = this.value;
            todosConnection.save(todo);
        }
    };

    return element;
};


document.getElementById('maker').onclick = function(){
    var element = makeTodoNamer(5);
    document.body.appendChild(element);
};
this is a can-connect example, done w/o can.Map
it uses connection.addInstanceReference to keep things in a store, and Object.observe to bind on them