This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
JL Flores Mena
Posted Feb 08 - Read on Facebook

Hey everyone, I'm having an issue with the latest version, it throws this error on my previously working projects: "Layer.on needs a valid event name".

I think this happens on projects where I'm using custom event listeners, like:
myLayer.on "change:customAttribute", ->

I'll try to replicate in a project that I can share, but just wanted to know if you've encountered this issue.

And btw, Framer team: awesome work on the new update, this makes your subscription model so valuable!

23 Comments

Koen Bok

Yeah I'd love to see a small repro and fix it. Thanks!

Chris Camargo

Koen Bok, in the meantime, what's the best way to rollback Studio to an earlier version?

Koen Bok

I think you only have to replace your framer.js for this. You can find the old version in the framer folder in your project if you updated through Studio. If not, you can download any old version here: http://builds.framerjs.com/

Koen Bok

Hey I tried to repro this but cannot. The error is easy, it is expecting some string value for the event, in your case "change:customAttribute". Are you sure you are passing an actual event in your code?

Chris Camargo

I think I tracked down the problem. We had been attaching properties arbitrarily to the Events object in some of our modules like so:
@emit Events.Change

Then checking for it using:
layer.on Events.Change

It appears that changing this to a string fixes the problem.

Chris Camargo

I am curious about why this changed, though.

Koen Bok

What type was Events.Change, a number?

Koen Bok

The reason why I built this check in was that you can make a typo like Events.Cilck and those are really hard to spot.

Chris Camargo

No, we just emitted Events.Change. Never assigned it anything.

Koen Bok

But then it's `undefined` right? So Events.Change would also trigger Events.Anything.

Chris Camargo

Hahaha! Oh man... so many bugs we ran into make so much sense right now. You're absolutely right.

JL Flores Mena

Awesome finding Chris, yes, it works if in my module I change
@emit Events.Change
to @emit "Events.Change"

Then in my Framer project I use
myLayer.on "Events.Change"

And yes Koen, this was the same as Events.Anything, definitely bad form we had in there...

Koen Bok

Well, we know that the check works at least. Now if it were only less confusing :-)

Chris Camargo

This raises another question for you, Koen. Why did you guys abstract the strings to the Events object in the first place?

Koen Bok

So we could do autocomplete like Events. ... But now we have layer.on... which is a lot nicer I think.

Koen Bok

Also because it's good to have them organized somewhere I guess. You can still totally use the dom events like "mouseover".

Alex Bystrov

I've the same issue, here is the same project with previous version of Framer: http://share.framerjs.com/xj567e08fgbk/ and this is the same code with updated Framer (does not work and gives me this error) http://share.framerjs.com/umsd3vzlix8q/

Alex Bystrov

Koen Bok so is this one a bug?

Koen Bok

Not really, it is a stricter check to avoid errors. This means you did not pass an event name so like layer.on(undefined, ...). I check for this because it can lead to very unexpected results.

Alex Bystrov

You mean like this? or what am I doing wrong now? http://share.framerjs.com/dx6g5fr5jfap/

Alex Bystrov

by the way, the original project works perfectly without adding (event) in all cases but one: it seems that "DragAnimationDidEnd" does not work in the new version of Framer

Koen Bok

I'll add aliases for DragAnimationDidEnd

Alex Bystrov

Thanks! btw not one of these actually works now

Read the entire post on Facebook