Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 14 21:13
    greenkeeper[bot] labeled #5378
  • Oct 14 21:12
    greenkeeper[bot] opened #5378
  • Oct 14 21:12

    greenkeeper[bot] on can-simple-map-4.3.3

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

  • Oct 14 20:19
    greenkeeper[bot] labeled #5377
  • Oct 14 20:19
    greenkeeper[bot] opened #5377
  • Oct 14 20:19

    greenkeeper[bot] on @feathersjs

    chore(package): update @feather… (compare)

  • Oct 14 20:18
    greenkeeper[bot] labeled #5376
  • Oct 14 20:18
    greenkeeper[bot] opened #5376
  • Oct 14 20:18

    greenkeeper[bot] on @feathersjs

    chore(package): update @feather… (compare)

  • Oct 14 14:43
    greenkeeper[bot] closed #5373
  • Oct 14 14:43

    greenkeeper[bot] on can-deep-observable-1.0.1

    (compare)

  • Oct 14 14:42

    m-mujica on update-deep-observable

    (compare)

  • Oct 14 14:42

    m-mujica on master

    Update can-deep-observable to l… Merge pull request #5374 from c… (compare)

  • Oct 14 14:42
    m-mujica closed #5374
  • Oct 14 14:42
    m-mujica closed #5365
  • Oct 14 14:09
    f-ricci starred canjs/canjs
  • Oct 14 13:55
    greenkeeper[bot] commented #5375
  • Oct 14 13:55

    greenkeeper[bot] on core-js-3.3.2

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

  • Oct 14 10:51
    m-mujica review_requested #5374
  • Oct 14 07:43
    rjgotten commented #5358
Guido Smeets
@gsmeets
anyone got any experience integrating a pubsub library like postal into a canjs drive application?
Szabolcs Schmidt
@sszabolcs

When binding a property on child component do I have to transform child property name from camel case?
From this:

<child-comp {{childProp}}="propOnParent" />

To this:

<child-comp {{child-prop}}="propOnParent" />

I'm using CanJS 3.8.0 with DefineMaps on both parent and child side.

Kevin Phillips
@phillipskevin
Yes, you do @sszabolcs
Szabolcs Schmidt
@sszabolcs
Thanks @phillipskevin
Justin Meyer
@justinbmeyer
@dbleier weigh in on what?
Brad Momberger
@bmomberger-bitovi
My take on the problem is https://gitter.im/canjs/canjs?at=592d95d50a783b6c0aecc10e but you may have better insight on it.
Justin Meyer
@justinbmeyer
Yeah, I think you are right @bmomberger-bitovi . @dbleier check this out: http://canjs.com/doc/can-set.html#SolvingCommonIssues
Matthew Phillips
@matthewp
Gregg Roemhildt
@roemhildtg
@gsmeets I'm using pubsub-js in a canjs app. Just for simple message publishing though, to notify user of async success and failure events.
Gregg Roemhildt
@roemhildtg
I'm running into an error involving can-stache-bindings and can-view-model.
can-stache-bindings data is calling canViewModel on an element, and for some reason that element has a .length property, which throws an error in can-view-model
Its happening in a stache template where a select dropdown has a two way binding like this: {($value)}="value"
Brad Momberger
@bmomberger-bitovi
Are you using can-jquery/legacy?
Gregg Roemhildt
@roemhildtg
Nope, I mean jquery is used in various places for ajax, but not can-jquery
Brad Momberger
@bmomberger-bitovi
Hm.. You're right, it looks like can-view-model does an isArrayLike test on the element and unboxes it to the 0-index if so.
Should file a bug on that.
Trying to think of a workaround until we fix that, but the best I can think of is to set the property "0" on the element to point back to itself.
What kind of element is it?
Gregg Roemhildt
@roemhildtg
Its a <select> element. But its burried in a component structure. Its weird because if I set a break point there, this is the only element that actually has a length property. I don't think its typical to have an element with a .length prop...
image.png
Brad Momberger
@bmomberger-bitovi
May we see your tag HTML that creates that select?
(stache bindings included)
Gregg Roemhildt
@roemhildtg
<select {($value)}="value" class="form-select form-control" name="{{properties.name}}">
    {{#each properties.options}}
        <option value="{{value}}">{{label}}</option>
    {{/each}}
</select>
Brad Momberger
@bmomberger-bitovi
I can definitely replicate this result in a JSBin. https://jsbin.com/jiqegoxudi/edit?html,js,console,output
Let me see if I can figure out where it's happening.
Gregg Roemhildt
@roemhildtg
hm, yes the tricky part
Brad Momberger
@bmomberger-bitovi
It's not us doing this; it seems like select elements always have a numeric length.
(equal to the number of options)
So I think the safest thing to do is to check in canViewModel whether el is an instance of Node and short-circuit the arraylike test.
Gregg Roemhildt
@roemhildtg
Mmhm that makes sense
Brad Momberger
@bmomberger-bitovi
Though, could you paste in a stack trace and the conditions where it throws? I am not seeing errors thrown in the JSBin when rendering or changing the select value
Gregg Roemhildt
@roemhildtg
Its quite a large stack trace, I'll make a pastebin
You have to call canViewModel on that element. Then it throws the error
Although I'm not calling canViewModel directly, can-stache-bindings does in the data method
Brad Momberger
@bmomberger-bitovi
Just FYI, it should be lastElementChild, as lastChild is a text node.
A-ha! I see what happened here. This is something that broke in 3.2.0 because we added support for jQueries.
There you go. You can downgrade to can-view-model 3.1.3 which doesn't do array-like or string selector checks until we get the fix in.
Gregg Roemhildt
@roemhildtg
Sweet!
Thanks for taking a look, as always :smile:
Brad Momberger
@bmomberger-bitovi
you're welcome. I'll write up an issue in Github for this as soon as I put together a JSBin not using the global dist.
Brad Momberger
@bmomberger-bitovi
The other thing I noticed is, this only breaks if you don't have any options in your select.
Gregg Roemhildt
@roemhildtg
That's something to look into...not sure why my options are empty. It must be just initially, they eventually get populated :smile:
Brad Momberger
@bmomberger-bitovi
But anyway, canjs/can-view-model#31 is up now. I'll see if someone else wants to take it on or comment
Pedro Mendes
@pmgmendes
@frank-dspeed Thanks for the hint. My issue was related to a bug that meanwhile @justinbmeyer solved.
The topic thread a test case showcasing my intention.
Thanks for the help!
gregorgodoy
@gregorgodoy
Hi everyone! I have a question about natural ids and the save method. Usually id's are generated server side by the API (surrogate key), but sometimes the id is a natural key and is specified in the app. An example could be a country list, where the id is the three-letter country code. If i create a new country instance and call the method save() it will do a PUT to the API, because save evaluates if the id attribute is present and has a value to determine if its a new instance or a already persisted instance in database. How to solve this cases? Its there a way to call explicit the createData method instead of updateData? THANKS
Brad Momberger
@bmomberger-bitovi
@gregorgodoy a common pattern we use in the model layer is to create the model definition as a subclass of DefineMap, and add the connection that maps to it as a static property on the class (we usually use the property name Connection with a capital C. Then you can explicitly call CountryModel.Connection.createData(this.serialize(), this._cid)
The other option is to override isNew() and use some other criteria than the presence of the idProp to determine whether to create or update. How will you know whether an object has been created yet or not?
gregorgodoy
@gregorgodoy

@bmomberger-bitovi thanks for your reply and suggestions! I tried your suggestion and is almost working. For sure i misunderstood something. Here the model:

import DefineMap from 'can-define/map/';
import DefineList from 'can-define/list/';
import set from 'can-set';
import superMap from 'can-connect/can/super-map/';
import loader from '@loader';

const Multimedia = DefineMap.extend({
    seal: true
}, {
    'filename': 'string',
    'mime': 'string',
    'size': 'string',
    'original_name': 'string'
});

const algebra = new set.Algebra(
    set.props.id('filename')
);

Multimedia.List = DefineList.extend({
    '#': Multimedia
});

Multimedia.connection = superMap({
    url: {
        createData: function(param) {
            return new Promise(function(resolve,reject) {
                $.ajax({
                    url: loader.serviceBaseURL + '/multimedia',
                    type: 'POST',
                    dataType: 'json',
                    data: param,
                    headers: {
                        Prefer: 'return=representation',
                        Accept: 'application/vnd.pgrst.object+json'
                    }
                }).then(resolve, reject);
            });
        }

    },
    Map: Multimedia,
    List: Multimedia.List,
    name: 'multimedia',
    algebra
});

export default Multimedia;

and then i tried the following:

model =  new Multimedia({
    filename: '131232-2131231-23123.jpg',
    mime: 'image/jpeg',
    size: '1243',
    original_name: 'portrait.jpg'
})
model.constructor.connection.createData(model.serialize(), model._cid);

And the createData is called!! And the model is persisted in the API. GREAT!! But, immediately donejs throws an error:

Potentially unhandled rejection [2] TypeError: Cannot use 'in' operator to search for '__get' in undefined at readObservabe (http://baker:81/node_modules/can-connect/can/map/map.js:746:13)

and the exactly line is:

var readObservabe = function(instance, prop){
    if("__get" in instance) {
        if(callCanReadingOnIdRead) {
            Observation.add(instance, prop);
        }
        return instance.__get(prop);
    } else {
        if(callCanReadingOnIdRead) {
            return instance[prop];
        } else {
            return Observation.ignore(function(){
                return instance[prop];
            })();
        }
    }
};